aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dickinson <Andrew-Dickinson@users.noreply.github.com>2020-04-26 08:20:24 -0400
committerGitHub <noreply@github.com>2020-04-26 14:20:24 +0200
commit2c32c6190c391b165000584b9d15c668000d1dcc (patch)
treecedb6ed97162090587c555c16a6099af630c9711
parent27cac869d3131d09c7e0ca73e110288a7db324ac (diff)
downloadihatemoney-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
-rwxr-xr-xihatemoney/migrations/env.py9
-rw-r--r--ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py38
2 files changed, 36 insertions, 11 deletions
diff --git a/ihatemoney/migrations/env.py b/ihatemoney/migrations/env.py
index 4d4729c..0bd0031 100755
--- a/ihatemoney/migrations/env.py
+++ b/ihatemoney/migrations/env.py
@@ -41,7 +41,7 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
- context.configure(url=url)
+ context.configure(url=url, include_object=include_object)
with context.begin_transaction():
context.run_migrations()
@@ -75,6 +75,7 @@ def run_migrations_online():
context.configure(
connection=connection,
target_metadata=target_metadata,
+ include_object=include_object,
process_revision_directives=process_revision_directives,
**current_app.extensions["migrate"].configure_args
)
@@ -86,6 +87,12 @@ def run_migrations_online():
connection.close()
+def include_object(object, name, type_, reflected, compare_to):
+ if name == "sqlite_sequence":
+ return False
+ return True
+
+
if context.is_offline_mode():
run_migrations_offline()
else:
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"