Skip to content

Commit 07b48fa

Browse files
committed
Format migration code
1 parent d79b499 commit 07b48fa

File tree

1 file changed

+57
-36
lines changed

1 file changed

+57
-36
lines changed

migrations/versions/28e53a4e60fe_add_combo_multipliers.py

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,81 @@
55
Create Date: 2025-01-14 22:48:14.773004
66
77
"""
8+
89
from alembic import op
910
import sqlalchemy as sa
1011

1112

1213
# revision identifiers, used by Alembic.
13-
revision = '28e53a4e60fe'
14-
down_revision = 'fa5ff0ea7eab'
14+
revision = "28e53a4e60fe"
15+
down_revision = "fa5ff0ea7eab"
1516
branch_labels = None
1617
depends_on = None
1718

1819

1920
def upgrade():
2021
# ### commands auto generated by Alembic - please adjust! ###
21-
with op.batch_alter_table('task', schema=None) as batch_op:
22-
batch_op.alter_column('streak',
23-
existing_type=sa.INTEGER(),
24-
nullable=False,
25-
existing_server_default=sa.text('0'))
26-
batch_op.alter_column('completed',
27-
existing_type=sa.INTEGER(),
28-
type_=sa.Boolean(),
29-
existing_nullable=False,
30-
existing_server_default=sa.text('0'))
22+
with op.batch_alter_table("task", schema=None) as batch_op:
23+
batch_op.alter_column(
24+
"streak",
25+
existing_type=sa.INTEGER(),
26+
nullable=False,
27+
existing_server_default=sa.text("0"),
28+
)
29+
batch_op.alter_column(
30+
"completed",
31+
existing_type=sa.INTEGER(),
32+
type_=sa.Boolean(),
33+
existing_nullable=False,
34+
existing_server_default=sa.text("0"),
35+
)
3136

32-
with op.batch_alter_table('user', schema=None) as batch_op:
33-
batch_op.add_column(sa.Column('combo_multiplier', sa.Integer(), nullable=False, server_default='0'))
34-
batch_op.add_column(sa.Column('last_task_completed', sa.Integer(), nullable=False, server_default='-1'))
35-
batch_op.alter_column('tasks_completed',
36-
existing_type=sa.INTEGER(),
37-
nullable=False,
38-
existing_server_default=sa.text('0'))
37+
with op.batch_alter_table("user", schema=None) as batch_op:
38+
batch_op.add_column(
39+
sa.Column(
40+
"combo_multiplier", sa.Integer(), nullable=False, server_default="0"
41+
)
42+
)
43+
batch_op.add_column(
44+
sa.Column(
45+
"last_task_completed", sa.Integer(), nullable=False, server_default="-1"
46+
)
47+
)
48+
batch_op.alter_column(
49+
"tasks_completed",
50+
existing_type=sa.INTEGER(),
51+
nullable=False,
52+
existing_server_default=sa.text("0"),
53+
)
3954

4055
# ### end Alembic commands ###
4156

4257

4358
def downgrade():
4459
# ### commands auto generated by Alembic - please adjust! ###
45-
with op.batch_alter_table('user', schema=None) as batch_op:
46-
batch_op.alter_column('tasks_completed',
47-
existing_type=sa.INTEGER(),
48-
nullable=True,
49-
existing_server_default=sa.text('0'))
50-
batch_op.drop_column('last_task_completed')
51-
batch_op.drop_column('combo_multiplier')
60+
with op.batch_alter_table("user", schema=None) as batch_op:
61+
batch_op.alter_column(
62+
"tasks_completed",
63+
existing_type=sa.INTEGER(),
64+
nullable=True,
65+
existing_server_default=sa.text("0"),
66+
)
67+
batch_op.drop_column("last_task_completed")
68+
batch_op.drop_column("combo_multiplier")
5269

53-
with op.batch_alter_table('task', schema=None) as batch_op:
54-
batch_op.alter_column('completed',
55-
existing_type=sa.Boolean(),
56-
type_=sa.INTEGER(),
57-
existing_nullable=False,
58-
existing_server_default=sa.text('0'))
59-
batch_op.alter_column('streak',
60-
existing_type=sa.INTEGER(),
61-
nullable=True,
62-
existing_server_default=sa.text('0'))
70+
with op.batch_alter_table("task", schema=None) as batch_op:
71+
batch_op.alter_column(
72+
"completed",
73+
existing_type=sa.Boolean(),
74+
type_=sa.INTEGER(),
75+
existing_nullable=False,
76+
existing_server_default=sa.text("0"),
77+
)
78+
batch_op.alter_column(
79+
"streak",
80+
existing_type=sa.INTEGER(),
81+
nullable=True,
82+
existing_server_default=sa.text("0"),
83+
)
6384

6485
# ### end Alembic commands ###

0 commit comments

Comments
 (0)