"""202512261547

Revision ID: a6452760a140
Revises: 5531240c344d
Create Date: 2025-12-26 15:57:33.025049

"""
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 = 'a6452760a140'
down_revision: Union[str, None] = '5531240c344d'
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('multi_agent_configs', sa.Column('default_model_config_id', sa.UUID(), nullable=True, comment='默认模型配置ID'))
    op.add_column('multi_agent_configs', sa.Column('model_parameters', postgresql.JSON(astext_type=sa.Text()), nullable=True, comment='模型参数配置（temperature、max_tokens等）'))
    op.alter_column('multi_agent_configs', 'master_agent_id',
               existing_type=sa.UUID(),
               nullable=True,
               existing_comment='主 Agent 发布版本 ID')
    op.create_index(op.f('ix_multi_agent_configs_default_model_config_id'), 'multi_agent_configs', ['default_model_config_id'], unique=False)
    op.create_foreign_key('multi_agent_configs_default_model_config_id_fkey', 'multi_agent_configs', 'model_configs', ['default_model_config_id'], ['id'])
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('multi_agent_configs_default_model_config_id_fkey', 'multi_agent_configs', type_='foreignkey')
    op.drop_index(op.f('ix_multi_agent_configs_default_model_config_id'), table_name='multi_agent_configs')
    op.alter_column('multi_agent_configs', 'master_agent_id',
               existing_type=sa.UUID(),
               nullable=False,
               existing_comment='主 Agent 发布版本 ID')
    op.drop_column('multi_agent_configs', 'model_parameters')
    op.drop_column('multi_agent_configs', 'default_model_config_id')
    # ### end Alembic commands ###
