From 210bbef92cb54e8c3f1daee26ccc0de7a1af934b Mon Sep 17 00:00:00 2001 From: John Davis Date: Tue, 11 Apr 2023 17:17:08 -0400 Subject: [PATCH] Wrap batch ops in pragma statement for sqlite See https://github.com/sqlalchemy/alembic/issues/1207 --- lib/galaxy/model/migrations/util.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/galaxy/model/migrations/util.py b/lib/galaxy/model/migrations/util.py index d4d232c0fb58..4ca98aba936d 100644 --- a/lib/galaxy/model/migrations/util.py +++ b/lib/galaxy/model/migrations/util.py @@ -27,8 +27,10 @@ def add_column(table_name: str, column: sa.Column) -> None: log.info("Generation of `alter` statements is disabled in offline mode.") return if _is_sqlite(): + op.execute("PRAGMA legacy_alter_table=1;") with op.batch_alter_table(table_name) as batch_op: batch_op.add_column(column) + op.execute("PRAGMA legacy_alter_table=0;") else: op.add_column(table_name, column) @@ -38,8 +40,10 @@ def drop_column(table_name, column_name): log.info("Generation of `alter` statements is disabled in offline mode.") return if _is_sqlite(): + op.execute("PRAGMA legacy_alter_table=1;") with op.batch_alter_table(table_name) as batch_op: batch_op.drop_column(column_name) + op.execute("PRAGMA legacy_alter_table=0;") else: op.drop_column(table_name, column_name)