mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
Fix sqlite only migration. (#579)
This commit is contained in:
parent
d6d084f26a
commit
6129191b26
4 changed files with 41 additions and 31 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -11,4 +11,4 @@ build
|
|||
.vscode
|
||||
.env
|
||||
.pytest_cache
|
||||
|
||||
ihatemoney/budget.db
|
||||
|
|
|
@ -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}
|
||||
),
|
||||
]
|
||||
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
|
||||
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}
|
||||
),
|
||||
]
|
||||
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
|
||||
for batch_op in alter_table_batches:
|
||||
with batch_op:
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue