Skip to content

Commit 377e440

Browse files
committed
Add new migration
1 parent 0c9a3e6 commit 377e440

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""Add time multiplier
2+
3+
Revision ID: fc7b30bd8065
4+
Revises: 28e53a4e60fe
5+
Create Date: 2025-01-20 21:04:17.318407
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = 'fc7b30bd8065'
14+
down_revision = '28e53a4e60fe'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### 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'))
31+
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'))
39+
40+
# ### end Alembic commands ###
41+
42+
43+
def downgrade():
44+
# ### 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')
52+
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'))
63+
64+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)