Skip to content

Commit

Permalink
Wrap batch ops in pragma statement for sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Apr 13, 2023
1 parent cf52f76 commit 210bbef
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/galaxy/model/migrations/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit 210bbef

Please sign in to comment.