|
5 | 5 | Create Date: 2025-01-20 21:04:17.318407 |
6 | 6 |
|
7 | 7 | """ |
| 8 | + |
8 | 9 | from alembic import op |
9 | 10 | import sqlalchemy as sa |
10 | 11 |
|
11 | 12 |
|
12 | 13 | # revision identifiers, used by Alembic. |
13 | | -revision = 'fc7b30bd8065' |
14 | | -down_revision = '28e53a4e60fe' |
| 14 | +revision = "fc7b30bd8065" |
| 15 | +down_revision = "28e53a4e60fe" |
15 | 16 | branch_labels = None |
16 | 17 | depends_on = None |
17 | 18 |
|
18 | 19 |
|
19 | 20 | def upgrade(): |
20 | 21 | # ### 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 | + ) |
31 | 36 |
|
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 | + ) |
39 | 57 |
|
40 | 58 | # ### end Alembic commands ### |
41 | 59 |
|
42 | 60 |
|
43 | 61 | def downgrade(): |
44 | 62 | # ### 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") |
52 | 72 |
|
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 | + ) |
63 | 87 |
|
64 | 88 | # ### end Alembic commands ### |
0 commit comments