aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy HUBSCHER <hubscher.remy@gmail.com>2020-04-25 11:55:46 +0200
committerGitHub <noreply@github.com>2020-04-25 11:55:46 +0200
commit6129191b26784b895e203fa3eafb89cee7d88b71 (patch)
tree5ad02feb6ca0f9c918810dfcdb92ed819237d499
parentd6d084f26a9de543527486e3c1fbc4e9100fddbd (diff)
downloadihatemoney-mirror-6129191b26784b895e203fa3eafb89cee7d88b71.zip
ihatemoney-mirror-6129191b26784b895e203fa3eafb89cee7d88b71.tar.gz
ihatemoney-mirror-6129191b26784b895e203fa3eafb89cee7d88b71.tar.bz2
Fix sqlite only migration. (#579)
-rw-r--r--.gitignore4
-rw-r--r--docs/contributing.rst2
-rw-r--r--ihatemoney/budget.db0
-rw-r--r--ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py70
4 files changed, 43 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore
index 1b9de4d..927a8d6 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 3401524..8e0d69a 100644
--- a/docs/contributing.rst
+++ b/docs/contributing.rst
@@ -220,7 +220,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 e69de29..0000000
--- a/ihatemoney/budget.db
+++ /dev/null
diff --git a/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py b/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py
index ae5ab32..718aa75 100644
--- a/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py
+++ b/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py
@@ -15,36 +15,46 @@ import sqlalchemy as sa
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