7670a05866_.py 2.73 KB
Newer Older
Hinrikus Wolf's avatar
Hinrikus Wolf committed
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
"""empty message

Revision ID: 7670a05866
Revises: 68688a3014
Create Date: 2015-11-07 12:14:03.278207

"""

# revision identifiers, used by Alembic.
revision = '7670a05866'
down_revision = '68688a3014'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('topics',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('mode', sa.String(), nullable=True),
    sa.Column('event_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['event_id'], ['events.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.drop_column('events', 'mode')
    op.add_column('speakers', sa.Column('event_id', sa.Integer(), nullable=False))
    op.drop_constraint('speakers_event_fkey', 'speakers', type_='foreignkey')
    op.create_foreign_key(None, 'speakers', 'events', ['event_id'], ['id'])
    op.drop_column('speakers', 'event')
    op.add_column('statements', sa.Column('event_id', sa.Integer(), nullable=False))
    op.add_column('statements', sa.Column('speaker_id', sa.Integer(), nullable=False))
    op.drop_constraint('statements_event_fkey', 'statements', type_='foreignkey')
    op.drop_constraint('statements_speaker_fkey', 'statements', type_='foreignkey')
    op.create_foreign_key(None, 'statements', 'events', ['event_id'], ['id'])
    op.create_foreign_key(None, 'statements', 'speakers', ['speaker_id'], ['id'])
    op.drop_column('statements', 'event')
    op.drop_column('statements', 'speaker')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('statements', sa.Column('speaker', sa.INTEGER(), autoincrement=False, nullable=False))
    op.add_column('statements', sa.Column('event', sa.INTEGER(), autoincrement=False, nullable=False))
    op.drop_constraint(None, 'statements', type_='foreignkey')
    op.drop_constraint(None, 'statements', type_='foreignkey')
    op.create_foreign_key('statements_speaker_fkey', 'statements', 'speakers', ['speaker'], ['id'])
    op.create_foreign_key('statements_event_fkey', 'statements', 'events', ['event'], ['id'])
    op.drop_column('statements', 'speaker_id')
    op.drop_column('statements', 'event_id')
    op.add_column('speakers', sa.Column('event', sa.INTEGER(), autoincrement=False, nullable=False))
    op.drop_constraint(None, 'speakers', type_='foreignkey')
    op.create_foreign_key('speakers_event_fkey', 'speakers', 'events', ['event'], ['id'])
    op.drop_column('speakers', 'event_id')
    op.add_column('events', sa.Column('mode', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.drop_table('topics')
    ### end Alembic commands ###