Skip to content

Commit d34ef0a

Browse files
committed
fix:修正二开迁移文件报错
1 parent 27918df commit d34ef0a

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

api/migrations_extend/versions/2025_03_31_2136-588f1696997b_add_system_integration_extend.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@ def upgrade():
2727
if 'system_integration_extend' not in tables:
2828
op.create_table('system_integration_extend',
2929
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
30-
sa.Column('classify', sa.Integer(), server_default=sa.text('1'), nullable=False, comment='集成类型'),
31-
sa.Column('status', sa.Boolean(), server_default=sa.text('false'), nullable=False, comment='配置启用状态'),
32-
sa.Column('corp_id', sa.Text(), nullable=True, comment='企业id'),
33-
sa.Column('agent_id', sa.Text(), nullable=True, comment='代理Id'),
34-
sa.Column('app_key', sa.Text(), nullable=True, comment='加密key'),
35-
sa.Column('app_secret', sa.Text(), nullable=True, comment='加密密钥'),
36-
sa.Column('test', sa.Boolean(), server_default=sa.text('false'), nullable=True, comment='是否测试链接联通性'),
37-
sa.Column('config', sa.Text(), nullable=True, comment='其他配置'),
38-
sa.Column('app_id', sa.Text(), nullable=True, comment='应用ID'),
30+
sa.Column('classify', sa.Integer(), server_default=sa.text('1'), nullable=False),
31+
sa.Column('status', sa.Boolean(), server_default=sa.text('false'), nullable=False),
32+
sa.Column('corp_id', sa.String(length=120), nullable=True),
33+
sa.Column('agent_id', sa.String(length=120), nullable=True),
34+
sa.Column('app_key', sa.String(length=120), nullable=True),
35+
sa.Column('app_secret', sa.Text(), nullable=True),
3936
sa.PrimaryKeyConstraint('id', name='system_integration_joins_pkey')
4037
)
4138
with op.batch_alter_table('system_integration_extend', schema=None) as batch_op:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""add_system_integration_extend_fields
2+
3+
Revision ID: 011_system_integration_fields
4+
Revises: 010_system_integration_extend
5+
Create Date: 2025-04-01 00:01:00.000000
6+
7+
"""
8+
from alembic import op
9+
from models import db, types
10+
import sqlalchemy as sa
11+
from sqlalchemy.engine.reflection import Inspector
12+
from sqlalchemy.dialects import postgresql
13+
14+
# revision identifiers, used by Alembic.
15+
revision = '011_system_integration_fields'
16+
down_revision = '010_system_integration_extend'
17+
branch_labels = None
18+
depends_on = None
19+
20+
21+
def upgrade():
22+
# ### commands auto generated by Alembic - please adjust! ###
23+
conn = op.get_bind()
24+
inspector = Inspector.from_engine(conn)
25+
tables = inspector.get_table_names()
26+
27+
if 'system_integration_extend' in tables:
28+
with op.batch_alter_table('system_integration_extend', schema=None) as batch_op:
29+
batch_op.add_column(sa.Column('test', sa.Boolean(), server_default=sa.text('false'), nullable=True, comment='是否测试链接联通性'))
30+
batch_op.add_column(sa.Column('config', sa.Text(), nullable=True, comment='其他配置'))
31+
batch_op.add_column(sa.Column('app_id', sa.Text(), nullable=True, comment='应用ID'))
32+
# ### end Alembic commands ###
33+
34+
35+
def downgrade():
36+
# ### commands auto generated by Alembic - please adjust! ###
37+
with op.batch_alter_table('system_integration_extend', schema=None) as batch_op:
38+
batch_op.drop_column('app_id')
39+
batch_op.drop_column('config')
40+
batch_op.drop_column('test')
41+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)