aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py
blob: ae5ab326a5c2d6d23d1b430bc5b7fe036150587a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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