"""202602041355

Revision ID: e7c7afa249d1
Revises: 9def72f79398
Create Date: 2026-02-04 13:55:22.284981

"""
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 = 'e7c7afa249d1'
down_revision: Union[str, None] = '9def72f79398'
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.create_table('skills',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('name', sa.String(), nullable=False, comment='技能名称'),
    sa.Column('description', sa.Text(), nullable=True, comment='技能描述'),
    sa.Column('tenant_id', sa.UUID(), nullable=False, comment='租户ID'),
    sa.Column('tools', postgresql.JSON(astext_type=sa.Text()), nullable=True, comment='关联的工具列表'),
    sa.Column('config', postgresql.JSON(astext_type=sa.Text()), nullable=True, comment='技能配置'),
    sa.Column('prompt', sa.Text(), nullable=True, comment='技能专属提示词'),
    sa.Column('is_active', sa.Boolean(), nullable=False, comment='是否激活'),
    sa.Column('is_public', sa.Boolean(), nullable=False, comment='是否公开到市场'),
    sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
    sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
    sa.ForeignKeyConstraint(['tenant_id'], ['tenants.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_skills_id'), 'skills', ['id'], unique=False)
    op.create_index(op.f('ix_skills_tenant_id'), 'skills', ['tenant_id'], unique=False)
    op.add_column('agent_configs', sa.Column('skill_ids', postgresql.JSON(astext_type=sa.Text()), nullable=True, comment='关联的技能ID列表'))
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('agent_configs', 'skill_ids')
    op.drop_index(op.f('ix_skills_tenant_id'), table_name='skills')
    op.drop_index(op.f('ix_skills_id'), table_name='skills')
    op.drop_table('skills')
    # ### end Alembic commands ###
