"""202511291902

Revision ID: d1e56ecbf058
Revises: e225ed10f5cb
Create Date: 2025-11-29 18:14:38.529466

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'd1e56ecbf058'
down_revision: Union[str, None] = 'e225ed10f5cb'
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.execute("DROP VIEW IF EXISTS data_config_sorted CASCADE")
    
    op.alter_column('data_config', 'llm_id',
               existing_type=sa.VARCHAR(),
               comment='LLM模型配置ID',
               existing_comment='临时',
               existing_nullable=True)
    op.drop_column('data_config', 'llm')
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('data_config', sa.Column('llm', sa.VARCHAR(), autoincrement=False, nullable=True, comment='LLM模型配置ID'))
    op.alter_column('data_config', 'llm_id',
               existing_type=sa.VARCHAR(),
               comment='临时',
               existing_comment='LLM模型配置ID',
               existing_nullable=True)
    # ### end Alembic commands ###
