From a2dfda34712eb318d76b925da166adfc8eaa5e3d Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 4 Feb 2026 13:57:20 +0800 Subject: [PATCH] [add] migration script --- .../versions/e7c7afa249d1_202602041355.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 api/migrations/versions/e7c7afa249d1_202602041355.py diff --git a/api/migrations/versions/e7c7afa249d1_202602041355.py b/api/migrations/versions/e7c7afa249d1_202602041355.py new file mode 100644 index 00000000..0559d5b4 --- /dev/null +++ b/api/migrations/versions/e7c7afa249d1_202602041355.py @@ -0,0 +1,50 @@ +"""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 ###