"""202604271530 Revision ID: 1f85dce125e5 Revises: 4e89970f9e7c Create Date: 2026-04-27 15:30:35.614679 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision: str = '1f85dce125e5' down_revision: Union[str, None] = '4e89970f9e7c' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.add_column('files', sa.Column('file_key', sa.String(length=512), nullable=True, comment='storage file key for FileStorageService')) op.create_index(op.f('ix_files_file_key'), 'files', ['file_key'], unique=False) op.alter_column('model_configs', 'capability', existing_type=postgresql.ARRAY(sa.VARCHAR()), comment="模型能力列表(如['vision', 'audio', 'video', 'thinking'])", existing_comment="模型能力列表(如['vision', 'audio', 'video'])", existing_nullable=False) # ### end Alembic commands ### op.execute(""" UPDATE files SET file_key = 'kb/' || kb_id::text || '/' || parent_id::text || '/' || id::text || file_ext WHERE file_ext != 'folder' AND file_key IS NULL """) def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.alter_column('model_configs', 'capability', existing_type=postgresql.ARRAY(sa.VARCHAR()), comment="模型能力列表(如['vision', 'audio', 'video'])", existing_comment="模型能力列表(如['vision', 'audio', 'video', 'thinking'])", existing_nullable=False) op.drop_index(op.f('ix_files_file_key'), table_name='files') op.drop_column('files', 'file_key') # ### end Alembic commands ###