Skip to content

Commit 436b806

Browse files
committed
Format migration code
1 parent 103ff86 commit 436b806

File tree

1 file changed

+60
-36
lines changed

1 file changed

+60
-36
lines changed

migrations/versions/fc7b30bd8065_add_time_multiplier.py

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,84 @@
55
Create Date: 2025-01-20 21:04:17.318407
66
77
"""
8+
89
from alembic import op
910
import sqlalchemy as sa
1011

1112

1213
# revision identifiers, used by Alembic.
13-
revision = 'fc7b30bd8065'
14-
down_revision = '28e53a4e60fe'
14+
revision = "fc7b30bd8065"
15+
down_revision = "28e53a4e60fe"
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('last_time_clicked', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False))
34-
batch_op.add_column(sa.Column('time_multiplier', sa.Integer(), server_default='1', nullable=False))
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+
"last_time_clicked",
41+
sa.DateTime(),
42+
server_default=sa.text("(CURRENT_TIMESTAMP)"),
43+
nullable=False,
44+
)
45+
)
46+
batch_op.add_column(
47+
sa.Column(
48+
"time_multiplier", sa.Integer(), server_default="1", nullable=False
49+
)
50+
)
51+
batch_op.alter_column(
52+
"tasks_completed",
53+
existing_type=sa.INTEGER(),
54+
nullable=False,
55+
existing_server_default=sa.text("0"),
56+
)
3957

4058
# ### end Alembic commands ###
4159

4260

4361
def downgrade():
4462
# ### 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('time_multiplier')
51-
batch_op.drop_column('last_time_clicked')
63+
with op.batch_alter_table("user", schema=None) as batch_op:
64+
batch_op.alter_column(
65+
"tasks_completed",
66+
existing_type=sa.INTEGER(),
67+
nullable=True,
68+
existing_server_default=sa.text("0"),
69+
)
70+
batch_op.drop_column("time_multiplier")
71+
batch_op.drop_column("last_time_clicked")
5272

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'))
73+
with op.batch_alter_table("task", schema=None) as batch_op:
74+
batch_op.alter_column(
75+
"completed",
76+
existing_type=sa.Boolean(),
77+
type_=sa.INTEGER(),
78+
existing_nullable=False,
79+
existing_server_default=sa.text("0"),
80+
)
81+
batch_op.alter_column(
82+
"streak",
83+
existing_type=sa.INTEGER(),
84+
nullable=True,
85+
existing_server_default=sa.text("0"),
86+
)
6387

6488
# ### end Alembic commands ###

0 commit comments

Comments
 (0)