Skip to content

Commit b46036e

Browse files
committed
Add rating score mutation
1 parent c0810b4 commit b46036e

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""Add rating score
2+
3+
Revision ID: ca738f81bbd0
4+
Revises: fc7b30bd8065
5+
Create Date: 2025-02-12 18:20:12.545218
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = 'ca738f81bbd0'
14+
down_revision = 'fc7b30bd8065'
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('rating', sa.Float(), server_default='0', nullable=False))
34+
batch_op.alter_column('tasks_completed',
35+
existing_type=sa.INTEGER(),
36+
nullable=False,
37+
existing_server_default=sa.text('0'))
38+
batch_op.alter_column('last_time_clicked',
39+
existing_type=sa.DATETIME(),
40+
nullable=False,
41+
existing_server_default=sa.text("'2025-01-20 00:00:00'"))
42+
43+
# ### end Alembic commands ###
44+
45+
46+
def downgrade():
47+
# ### commands auto generated by Alembic - please adjust! ###
48+
with op.batch_alter_table('user', schema=None) as batch_op:
49+
batch_op.alter_column('last_time_clicked',
50+
existing_type=sa.DATETIME(),
51+
nullable=True,
52+
existing_server_default=sa.text("'2025-01-20 00:00:00'"))
53+
batch_op.alter_column('tasks_completed',
54+
existing_type=sa.INTEGER(),
55+
nullable=True,
56+
existing_server_default=sa.text('0'))
57+
batch_op.drop_column('rating')
58+
59+
with op.batch_alter_table('task', schema=None) as batch_op:
60+
batch_op.alter_column('completed',
61+
existing_type=sa.Boolean(),
62+
type_=sa.INTEGER(),
63+
existing_nullable=False,
64+
existing_server_default=sa.text('0'))
65+
batch_op.alter_column('streak',
66+
existing_type=sa.INTEGER(),
67+
nullable=True,
68+
existing_server_default=sa.text('0'))
69+
70+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)