From 0160bbe7d6da7b61c0192a9ac3798f1fd895ebf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Sat, 25 Apr 2020 11:18:55 +0200 Subject: [PATCH] Fix sqlite only migration. --- .gitignore | 4 +- docs/contributing.rst | 2 +- ihatemoney/budget.db | 0 .../cb038f79982e_sqlite_autoincrement.py | 70 +++++++++++-------- 4 files changed, 43 insertions(+), 33 deletions(-) delete mode 100644 ihatemoney/budget.db diff --git a/.gitignore b/.gitignore index 1b9de4d98..927a8d641 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,5 @@ dist build .vscode .env -.pytest_cache - +.pytest_cache +ihatemoney/budget.db diff --git a/docs/contributing.rst b/docs/contributing.rst index 27f890b32..b58c67db2 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -187,7 +187,7 @@ In order to prepare a new release, we are following the following steps: make compress-assets - Build the translations:: - + make update-translations make build-translations diff --git a/ihatemoney/budget.db b/ihatemoney/budget.db deleted file mode 100644 index e69de29bb..000000000 diff --git a/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py b/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py index ae5ab326a..718aa75ae 100644 --- a/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py +++ b/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py @@ -15,36 +15,46 @@ def upgrade(): - alter_table_batches = [ - op.batch_alter_table( - "person", recreate="always", table_kwargs={"sqlite_autoincrement": True} - ), - op.batch_alter_table( - "bill", recreate="always", table_kwargs={"sqlite_autoincrement": True} - ), - op.batch_alter_table( - "billowers", recreate="always", table_kwargs={"sqlite_autoincrement": True} - ), - ] - - for batch_op in alter_table_batches: - with batch_op: - pass + bind = op.get_bind() + if bind.engine.name == "sqlite": + alter_table_batches = [ + op.batch_alter_table( + "person", recreate="always", table_kwargs={"sqlite_autoincrement": True} + ), + op.batch_alter_table( + "bill", recreate="always", table_kwargs={"sqlite_autoincrement": True} + ), + op.batch_alter_table( + "billowers", + recreate="always", + table_kwargs={"sqlite_autoincrement": True}, + ), + ] + + for batch_op in alter_table_batches: + with batch_op: + pass def downgrade(): - alter_table_batches = [ - op.batch_alter_table( - "person", recreate="always", table_kwargs={"sqlite_autoincrement": False} - ), - op.batch_alter_table( - "bill", recreate="always", table_kwargs={"sqlite_autoincrement": False} - ), - op.batch_alter_table( - "billowers", recreate="always", table_kwargs={"sqlite_autoincrement": False} - ), - ] - - for batch_op in alter_table_batches: - with batch_op: - pass + bind = op.get_bind() + if bind.engine.name == "sqlite": + alter_table_batches = [ + op.batch_alter_table( + "person", + recreate="always", + table_kwargs={"sqlite_autoincrement": False}, + ), + op.batch_alter_table( + "bill", recreate="always", table_kwargs={"sqlite_autoincrement": False} + ), + op.batch_alter_table( + "billowers", + recreate="always", + table_kwargs={"sqlite_autoincrement": False}, + ), + ] + + for batch_op in alter_table_batches: + with batch_op: + pass