-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure SQLite to disable ID reuse
- Loading branch information
1 parent
d008e88
commit e7848e3
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""sqlite_autoincrement | ||
Revision ID: cb038f79982e | ||
Revises: 2dcb0c0048dc | ||
Create Date: 2020-04-13 17:40:02.426957 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "cb038f79982e" | ||
down_revision = "2dcb0c0048dc" | ||
|
||
from alembic import op | ||
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 | ||
|
||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters