"""202511261433

Revision ID: f210d1844b07
Revises: 2e8146c98e3d
Create Date: 2025-11-26 14:33:56.077776

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'f210d1844b07'
down_revision: Union[str, None] = '2e8146c98e3d'
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.alter_column('knowledges', 'status',
               existing_type=sa.INTEGER(),
               comment='is it validate(0: disable, 1: enable, 2:Soft-delete)',
               existing_comment='is it validate(0: wasted, 1: validate)',
               existing_nullable=True)
    op.add_column('multi_agent_configs', sa.Column('master_agent_name', sa.String(length=100), nullable=True, comment='主 Agent 名称'))
    op.alter_column('multi_agent_configs', 'master_agent_id',
               existing_type=sa.UUID(),
               comment='主 Agent 发布版本 ID',
               existing_comment='主 Agent ID',
               existing_nullable=False)
    op.drop_constraint(op.f('multi_agent_configs_master_agent_id_fkey'), 'multi_agent_configs', type_='foreignkey')
    op.create_foreign_key(None, 'multi_agent_configs', 'app_releases', ['master_agent_id'], ['id'])
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'multi_agent_configs', type_='foreignkey')
    op.create_foreign_key(op.f('multi_agent_configs_master_agent_id_fkey'), 'multi_agent_configs', 'agent_configs', ['master_agent_id'], ['id'])
    op.alter_column('multi_agent_configs', 'master_agent_id',
               existing_type=sa.UUID(),
               comment='主 Agent ID',
               existing_comment='主 Agent 发布版本 ID',
               existing_nullable=False)
    op.drop_column('multi_agent_configs', 'master_agent_name')
    op.alter_column('knowledges', 'status',
               existing_type=sa.INTEGER(),
               comment='is it validate(0: wasted, 1: validate)',
               existing_comment='is it validate(0: disable, 1: enable, 2:Soft-delete)',
               existing_nullable=True)
    # ### end Alembic commands ###
