-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathb2cfada3abcd_add_participants.py
57 lines (49 loc) · 2.73 KB
/
b2cfada3abcd_add_participants.py
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
"""Add Participants
Revision ID: b2cfada3abcd
Revises: 1e08c4ac0ff8
Create Date: 2019-11-24 11:38:13.140683
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b2cfada3abcd'
down_revision = '1e08c4ac0ff8'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('Participants',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('event_id', sa.Integer(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['event_id'], ['Events.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['Users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_constraint('category_event_name_uc', 'Categories', type_='unique')
op.add_column('TeamMembers', sa.Column('participant_id', sa.Integer(), nullable=True))
op.drop_constraint('TeamMembers_user_id_fkey', 'TeamMembers', type_='foreignkey')
op.create_foreign_key('TeamMembers_participant_id_fkey', 'TeamMembers', 'Participants', ['participant_id'], ['id'])
op.drop_column('TeamMembers', 'user_id')
op.add_column('TeamRequests', sa.Column('participant_id', sa.Integer(), nullable=True))
op.drop_constraint('TeamRequests_user_id_fkey', 'TeamRequests', type_='foreignkey')
op.create_foreign_key('TeamRequests_participant_id_fkey', 'TeamRequests', 'Participants', ['participant_id'], ['id'])
op.drop_column('TeamRequests', 'user_id')
op.drop_constraint('Users_event_id_fkey', 'Users', type_='foreignkey')
op.drop_column('Users', 'event_id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('Users', sa.Column('event_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.create_foreign_key('Users_event_id_fkey', 'Users', 'Events', ['event_id'], ['id'])
op.add_column('TeamRequests', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.drop_constraint('TeamRequests_participant_id_fkey', 'TeamRequests', type_='foreignkey')
op.create_foreign_key('TeamRequests_user_id_fkey', 'TeamRequests', 'Users', ['user_id'], ['id'])
op.drop_column('TeamRequests', 'participant_id')
op.add_column('TeamMembers', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.drop_constraint('TeamMembers_participant_id_fkey', 'TeamMembers', type_='foreignkey')
op.create_foreign_key('TeamMembers_user_id_fkey', 'TeamMembers', 'Users', ['user_id'], ['id'])
op.drop_column('TeamMembers', 'participant_id')
op.create_unique_constraint('category_event_name_uc', 'Categories', ['event_id', 'name'])
op.drop_table('Participants')
# ### end Alembic commands ###