-
Notifications
You must be signed in to change notification settings - Fork 0
/
2022-08-14_6d3ed0c1b66e_added_default_column.py
71 lines (63 loc) · 2.17 KB
/
2022-08-14_6d3ed0c1b66e_added_default_column.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Added default column
Revision ID: 6d3ed0c1b66e
Revises: 8298e2141907
Create Date: 2022-08-14 00:54:06.072893
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "6d3ed0c1b66e"
down_revision = "8298e2141907"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"branches",
sa.Column(
"is_default", sa.Boolean(), server_default=sa.text("False"), nullable=True
),
)
op.add_column(
"concerns",
sa.Column(
"is_default", sa.Boolean(), server_default=sa.text("False"), nullable=True
),
)
op.add_column(
"goals",
sa.Column(
"is_default", sa.Boolean(), server_default=sa.text("False"), nullable=True
),
)
op.add_column(
"access_types",
sa.Column(
"is_default", sa.Boolean(), server_default=sa.text("False"), nullable=True
),
)
op.add_column(
"transportation_methods",
sa.Column(
"is_default", sa.Boolean(), server_default=sa.text("False"), nullable=True
),
)
op.execute("UPDATE branches SET is_default = true")
op.execute("UPDATE concerns SET is_default = true")
op.execute("UPDATE goals SET is_default = true")
op.execute("UPDATE access_types SET is_default = true")
op.execute("UPDATE transportation_methods SET is_default = true")
op.alter_column("branches", "is_default", nullable=False)
op.alter_column("concerns", "is_default", nullable=False)
op.alter_column("goals", "is_default", nullable=False)
op.alter_column("access_types", "is_default", nullable=False)
op.alter_column("transportation_methods", "is_default", nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("transportation_methods", "is_default")
op.drop_column("access_types", "is_default")
op.drop_column("goals", "is_default")
op.drop_column("concerns", "is_default")
op.drop_column("branches", "is_default")
# ### end Alembic commands ###