From ac25b6ff11aa02682cf9dd73aaffd4f094da1317 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 25 Dec 2025 17:51:27 +0800 Subject: [PATCH] [add] migrations script --- api/app/models/tool_model.py | 4 +-- .../versions/5531240c344d_202512251740.py | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 api/migrations/versions/5531240c344d_202512251740.py diff --git a/api/app/models/tool_model.py b/api/app/models/tool_model.py index f170148f..aec74ef7 100644 --- a/api/app/models/tool_model.py +++ b/api/app/models/tool_model.py @@ -130,8 +130,8 @@ class BuiltinToolConfig(Base): id = Column(UUID(as_uuid=True), ForeignKey("tool_configs.id"), primary_key=True) tool_class = Column(String(255), nullable=False) # 工具类名 parameters = Column(JSON, default=dict) # 工具参数配置 - is_enabled = Column(Boolean, default=False, nullable=False) # 启用开关 - requires_config = Column(Boolean, default=False, nullable=False) # 是否需要配置 + is_enabled = Column(Boolean, default=False, server_default='false', nullable=False) # 启用开关 + requires_config = Column(Boolean, default=False, server_default='false', nullable=False) # 是否需要配置 # 关联关系 base_config = relationship("ToolConfig", foreign_keys=[id]) diff --git a/api/migrations/versions/5531240c344d_202512251740.py b/api/migrations/versions/5531240c344d_202512251740.py new file mode 100644 index 00000000..50f46a94 --- /dev/null +++ b/api/migrations/versions/5531240c344d_202512251740.py @@ -0,0 +1,34 @@ +"""202512251740 + +Revision ID: 5531240c344d +Revises: 23f5ce1346ba +Create Date: 2025-12-25 17:47:06.575569 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '5531240c344d' +down_revision: Union[str, None] = '23f5ce1346ba' +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('builtin_tool_configs', sa.Column('is_enabled', sa.Boolean(), server_default='false', nullable=False)) + op.add_column('builtin_tool_configs', sa.Column('requires_config', sa.Boolean(), server_default='false', nullable=False)) + op.add_column('tool_configs', sa.Column('icon', sa.String(length=255), nullable=True)) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('tool_configs', 'icon') + op.drop_column('builtin_tool_configs', 'requires_config') + op.drop_column('builtin_tool_configs', 'is_enabled') + # ### end Alembic commands ###