From eff117e0eeaed5bb9b3d071e273f098c93f3ad25 Mon Sep 17 00:00:00 2001 From: SaintShit Date: Wed, 20 Dec 2023 14:17:25 +0330 Subject: [PATCH] fix: migration scripts for old sqlite versions --- ...15c2615f0_add_allow_in_secure_and_disable_host.py | 12 +++++------- .../migrations/versions/e56f1c781e46_fix_on_hold.py | 12 +++++------- .../fe7796f840a4_remove_certficiate_from_nodes.py | 12 ++++++------ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/app/db/migrations/versions/a0715c2615f0_add_allow_in_secure_and_disable_host.py b/app/db/migrations/versions/a0715c2615f0_add_allow_in_secure_and_disable_host.py index dadfba31e..08407b28b 100644 --- a/app/db/migrations/versions/a0715c2615f0_add_allow_in_secure_and_disable_host.py +++ b/app/db/migrations/versions/a0715c2615f0_add_allow_in_secure_and_disable_host.py @@ -18,19 +18,17 @@ def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### try: op.add_column('hosts', sa.Column('allowinsecure', sa.Boolean(), nullable=True)) except sqlalchemy.exc.OperationalError: - op.drop_column('hosts', 'allowinsecure') + with op.batch_alter_table('hosts') as batch_op: + batch_op.drop_column('allowinsecure') op.add_column('hosts', sa.Column('allowinsecure', sa.Boolean(), nullable=True)) op.add_column('hosts', sa.Column('is_disabled', sa.Boolean(), nullable=True)) - # ### end Alembic commands ### def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('hosts', 'is_disabled') - op.drop_column('hosts', 'allowinsecure') - # ### end Alembic commands ### + with op.batch_alter_table('hosts') as batch_op: + batch_op.drop_column('is_disabled') + batch_op.drop_column('allowinsecure') diff --git a/app/db/migrations/versions/e56f1c781e46_fix_on_hold.py b/app/db/migrations/versions/e56f1c781e46_fix_on_hold.py index 1626d9559..3b1ca7b81 100644 --- a/app/db/migrations/versions/e56f1c781e46_fix_on_hold.py +++ b/app/db/migrations/versions/e56f1c781e46_fix_on_hold.py @@ -16,16 +16,14 @@ def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### op.add_column('users', sa.Column('on_hold_timeout', sa.DateTime)) op.add_column('users', sa.Column('on_hold_expire_duration', sa.BigInteger(), nullable=True)) - op.drop_column('users', 'timeout') - # ### end Alembic commands ### + with op.batch_alter_table('users') as batch_op: + batch_op.drop_column('timeout') def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### op.add_column('users', sa.Column('timeout', sa.Integer)) - op.drop_column('users', 'on_hold_timeout') - op.drop_column('users', 'on_hold_expire_duration') - # ### end Alembic commands ### + with op.batch_alter_table('users') as batch_op: + batch_op.drop_column('on_hold_timeout') + batch_op.drop_column('on_hold_expire_duration') diff --git a/app/db/migrations/versions/fe7796f840a4_remove_certficiate_from_nodes.py b/app/db/migrations/versions/fe7796f840a4_remove_certficiate_from_nodes.py index 77e1e73a8..2da2d3bee 100644 --- a/app/db/migrations/versions/fe7796f840a4_remove_certficiate_from_nodes.py +++ b/app/db/migrations/versions/fe7796f840a4_remove_certficiate_from_nodes.py @@ -17,12 +17,12 @@ def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('nodes', 'certificate') - # ### end Alembic commands ### + with op.batch_alter_table('nodes') as batch_op: + batch_op.drop_column('certificate') def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('nodes', sa.Column('certificate', mysql.VARCHAR(length=2048), nullable=False, server_default='')) - # ### end Alembic commands ### + with op.batch_alter_table('nodes') as batch_op: + batch_op.add_column(sa.Column( + 'certificate', mysql.VARCHAR(length=2048), + nullable=False, server_default=''))