diff options
| author | Andrew Dickinson <Andrew-Dickinson@users.noreply.github.com> | 2020-04-26 08:20:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-26 14:20:24 +0200 |
| commit | 2c32c6190c391b165000584b9d15c668000d1dcc (patch) | |
| tree | cedb6ed97162090587c555c16a6099af630c9711 /ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py | |
| parent | 27cac869d3131d09c7e0ca73e110288a7db324ac (diff) | |
| download | ihatemoney-mirror-2c32c6190c391b165000584b9d15c668000d1dcc.zip ihatemoney-mirror-2c32c6190c391b165000584b9d15c668000d1dcc.tar.gz ihatemoney-mirror-2c32c6190c391b165000584b9d15c668000d1dcc.tar.bz2 | |
Direct Alembic to ignore the sqlite_sequence table (#586)
* Direct Alembic to ignore the sqlite_sequence table
* Direct Alembic to ignore the sqlite_sequence table
* Fix "Skipping unsupported ALTER" warning on database migration
Diffstat (limited to 'ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py')
| -rw-r--r-- | ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py b/ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py index 0800835..b0b4f44 100644 --- a/ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py +++ b/ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py @@ -165,21 +165,39 @@ def upgrade(): sa.Column("remote_addr", sa.String(length=50), nullable=True), sa.PrimaryKeyConstraint("id"), ) - op.add_column( - "project", - sa.Column( - "logging_preference", - sa.Enum("DISABLED", "ENABLED", "RECORD_IP", name="loggingmode"), - server_default="ENABLED", - nullable=False, - ), - ) + bind = op.get_bind() + if bind.engine.name == "sqlite": + with op.batch_alter_table("project", recreate="always") as batch_op: + batch_op.add_column( + sa.Column( + "logging_preference", + sa.Enum("DISABLED", "ENABLED", "RECORD_IP", name="loggingmode"), + server_default="ENABLED", + nullable=False, + ), + ) + else: + op.add_column( + "project", + sa.Column( + "logging_preference", + sa.Enum("DISABLED", "ENABLED", "RECORD_IP", name="loggingmode"), + server_default="ENABLED", + nullable=False, + ), + ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.drop_column("project", "logging_preference") + + bind = op.get_bind() + if bind.engine.name == "sqlite": + with op.batch_alter_table("project", recreate="always") as batch_op: + batch_op.drop_column("logging_preference") + else: + op.drop_column("project", "logging_preference") op.drop_table("transaction") op.drop_index( op.f("ix_project_version_transaction_id"), table_name="project_version" |
