Skip to content

Commit

Permalink
Fix sqlite only migration. (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
Natim authored Apr 25, 2020
1 parent d6d084f commit 6129191
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ dist
build
.vscode
.env
.pytest_cache

.pytest_cache
ihatemoney/budget.db
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Empty file removed ihatemoney/budget.db
Empty file.
70 changes: 40 additions & 30 deletions ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6129191

Please sign in to comment.