Skip to content

Commit d765313

Browse files
committed
Add migration for new session tables
1 parent 27d6da7 commit d765313

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""Create Sessions
2+
3+
Revision ID: 27f63e48c6c4
4+
Revises: d4e3b890e3d7
5+
Create Date: 2021-01-09 11:57:18.916146
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = '27f63e48c6c4'
13+
down_revision = 'd4e3b890e3d7'
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade() -> None:
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.create_table(
21+
'session',
22+
sa.Column('id', sa.Integer(), nullable=False),
23+
sa.Column('name', sa.String(), nullable=False),
24+
sa.Column('username', sa.String(), nullable=False),
25+
sa.Column(
26+
'created',
27+
sa.DateTime(timezone=True),
28+
server_default=sa.text('(CURRENT_TIMESTAMP)'),
29+
nullable=False,
30+
),
31+
sa.PrimaryKeyConstraint('id'),
32+
sa.UniqueConstraint('name'),
33+
)
34+
op.create_table(
35+
'choice_for_session',
36+
sa.Column('choice_id', sa.Integer(), nullable=False),
37+
sa.Column('session_id', sa.Integer(), nullable=False),
38+
sa.ForeignKeyConstraint(['choice_id'], ['choice_history.id']),
39+
sa.ForeignKeyConstraint(['session_id'], ['session.id']),
40+
sa.PrimaryKeyConstraint('choice_id', 'session_id'),
41+
)
42+
# ### end Alembic commands ###
43+
44+
45+
def downgrade() -> None:
46+
# ### commands auto generated by Alembic - please adjust! ###
47+
op.drop_table('choice_for_session')
48+
op.drop_table('session')
49+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)