Skip to content

Commit

Permalink
fix: migration scripts for old sqlite versions
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintShit committed Dec 20, 2023
1 parent f397a61 commit eff117e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
12 changes: 5 additions & 7 deletions app/db/migrations/versions/e56f1c781e46_fix_on_hold.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Original file line number Diff line number Diff line change
Expand Up @@ -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=''))

0 comments on commit eff117e

Please sign in to comment.