From 26f6fcb3adf3440d56c686ea87c8ee00a3724435 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Sun, 30 Jul 2023 13:00:55 -0400 Subject: [PATCH] Fixed missing table during migration of a new database. --- migrations/versions/dc09994b7e65_.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/migrations/versions/dc09994b7e65_.py b/migrations/versions/dc09994b7e65_.py index d91f9e38c..fd30258d8 100644 --- a/migrations/versions/dc09994b7e65_.py +++ b/migrations/versions/dc09994b7e65_.py @@ -24,6 +24,7 @@ depends_on = None bind = op.get_context().bind insp = sa.inspect(bind) +tables = insp.get_table_names() should_recreate = 'always' if bind.engine.name == 'sqlite' else 'auto' @@ -58,10 +59,11 @@ def upgrade(): batch_op.add_column(sa.Column('id', sa.Integer, primary_key=True)) # Update custom_score_profile_conditions table - with op.batch_alter_table('table_custom_score_profile_conditions') as batch_op: - batch_op.execute('DROP INDEX IF EXISTS tablecustomscoreprofileconditions_profile_id') - batch_op.alter_column('profile_id', index=False) - batch_op.execute('DROP INDEX IF EXISTS ix_table_custom_score_profile_conditions_profile_id;') + if 'table_custom_score_profile_conditions' in tables: + with op.batch_alter_table('table_custom_score_profile_conditions') as batch_op: + batch_op.execute('DROP INDEX IF EXISTS tablecustomscoreprofileconditions_profile_id') + batch_op.alter_column('profile_id', index=False) + batch_op.execute('DROP INDEX IF EXISTS ix_table_custom_score_profile_conditions_profile_id;') # Update notifier table with op.batch_alter_table('table_settings_notifier') as batch_op: