-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathd19dd2c3e751_initial_migration.py
More file actions
70 lines (54 loc) · 2.56 KB
/
Copy pathd19dd2c3e751_initial_migration.py
File metadata and controls
70 lines (54 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""Initial migration.
Revision ID: d19dd2c3e751
Revises:
Create Date: 2024-07-09 18:29:09.592453
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd19dd2c3e751'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('questionnaire_response', schema=None) as batch_op:
batch_op.add_column(sa.Column('question_id', sa.String(length=50), nullable=True))
batch_op.add_column(sa.Column('response', sa.String(length=1000), nullable=True))
batch_op.alter_column('user_id',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.drop_column('question3')
batch_op.drop_column('question2')
batch_op.drop_column('question1')
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.add_column(sa.Column('has_completed_questionnaire', sa.Boolean(), nullable=True))
with op.batch_alter_table('weight', schema=None) as batch_op:
batch_op.alter_column('user_id',
existing_type=sa.INTEGER(),
nullable=True)
with op.batch_alter_table('weight_entry', schema=None) as batch_op:
batch_op.add_column(sa.Column('date', sa.DateTime(), nullable=True))
batch_op.drop_column('date_added')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('weight_entry', schema=None) as batch_op:
batch_op.add_column(sa.Column('date_added', sa.DATETIME(), nullable=True))
batch_op.drop_column('date')
with op.batch_alter_table('weight', schema=None) as batch_op:
batch_op.alter_column('user_id',
existing_type=sa.INTEGER(),
nullable=False)
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.drop_column('has_completed_questionnaire')
with op.batch_alter_table('questionnaire_response', schema=None) as batch_op:
batch_op.add_column(sa.Column('question1', sa.VARCHAR(length=200), nullable=False))
batch_op.add_column(sa.Column('question2', sa.VARCHAR(length=200), nullable=False))
batch_op.add_column(sa.Column('question3', sa.VARCHAR(length=200), nullable=False))
batch_op.alter_column('user_id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.drop_column('response')
batch_op.drop_column('question_id')
# ### end Alembic commands ###