1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- """add_ballots_remove_page_file_relation
- Revision ID: c98e920c06ae
- Revises: d692d6e1a31d
- Create Date: 2019-03-29 17:49:34.434786
- """
- from alembic import op
- import sqlalchemy as sa
- # revision identifiers, used by Alembic.
- revision = 'c98e920c06ae'
- down_revision = 'd692d6e1a31d'
- branch_labels = None
- depends_on = None
- def upgrade():
- op.create_table('priority',
- sa.Column('id', sa.Integer(), nullable=False),
- sa.Column('name', sa.String(), nullable=False),
- sa.Column('description', sa.String(), nullable=False),
- sa.PrimaryKeyConstraint('id', name=op.f('pk_priority'))
- )
- op.create_table('ballot',
- sa.Column('id', sa.Integer(), nullable=False),
- sa.Column('name', sa.String(), nullable=False),
- sa.Column('description', sa.String(), nullable=True),
- sa.Column('start_at', sa.DateTime(), nullable=True),
- sa.Column('end_at', sa.DateTime(), nullable=False),
- sa.Column('user_id', sa.Integer(), nullable=True),
- sa.Column('priority_id', sa.Integer(), nullable=True),
- sa.ForeignKeyConstraint(['priority_id'], ['priority.id'], name=op.f('fk_ballot_priority_id_priority')),
- sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_ballot_user_id_user')),
- sa.PrimaryKeyConstraint('id', name=op.f('pk_ballot'))
- )
- op.create_table('question',
- sa.Column('id', sa.Integer(), nullable=False),
- sa.Column('name', sa.String(), nullable=False),
- sa.Column('description', sa.String(), nullable=True),
- sa.Column('ballot_id', sa.Integer(), nullable=True),
- sa.ForeignKeyConstraint(['ballot_id'], ['ballot.id'], name=op.f('fk_question_ballot_id_ballot')),
- sa.PrimaryKeyConstraint('id', name=op.f('pk_question'))
- )
- op.create_table('option',
- sa.Column('id', sa.Integer(), nullable=False),
- sa.Column('motivation', sa.String(), nullable=True),
- sa.Column('user_id', sa.Integer(), nullable=True),
- sa.Column('question_id', sa.Integer(), nullable=True),
- sa.ForeignKeyConstraint(['question_id'], ['question.id'], name=op.f('fk_option_question_id_question')),
- sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_option_user_id_user')),
- sa.PrimaryKeyConstraint('id', name=op.f('pk_option'))
- )
- op.create_table('vote',
- sa.Column('id', sa.Integer(), nullable=False),
- sa.Column('datetime', sa.DateTime(), nullable=True),
- sa.Column('option_id', sa.Integer(), nullable=True),
- sa.Column('user_id', sa.Integer(), nullable=True),
- sa.ForeignKeyConstraint(['option_id'], ['option.id'], name=op.f('fk_vote_option_id_option')),
- sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_vote_user_id_user')),
- sa.PrimaryKeyConstraint('id', name=op.f('pk_vote'))
- )
- op.drop_table('page_file')
- op.add_column('user', sa.Column('alt', sa.Boolean(), server_default='f', nullable=True))
- op.add_column('user', sa.Column('discord', sa.String(length=255), nullable=True))
- op.add_column('user', sa.Column('game_id', sa.BigInteger(), nullable=True))
- op.add_column('user', sa.Column('party_member', sa.Boolean(), server_default='f', nullable=True))
- op.add_column('user', sa.Column('question_id', sa.Integer(), nullable=True))
- op.create_unique_constraint(op.f('uq_user_discord'), 'user', ['discord'])
- op.create_unique_constraint(op.f('uq_user_game_id'), 'user', ['game_id'])
- op.create_foreign_key(op.f('fk_user_question_id_question'), 'user', 'question', ['question_id'], ['id'])
- def downgrade():
- op.drop_constraint(op.f('fk_user_question_id_question'), 'user', type_='foreignkey')
- op.create_unique_constraint('user_name_key', 'user', ['name'])
- op.drop_constraint(op.f('uq_user_name'), 'user', type_='unique')
- op.drop_constraint(op.f('uq_user_game_id'), 'user', type_='unique')
- op.drop_constraint(op.f('uq_user_email'), 'user', type_='unique')
- op.drop_constraint(op.f('uq_user_discord'), 'user', type_='unique')
- op.drop_column('user', 'question_id')
- op.drop_column('user', 'party_member')
- op.drop_column('user', 'game_id')
- op.drop_column('user', 'discord')
- op.drop_column('user', 'alt')
- op.create_table('page_file',
- sa.Column('page_id', sa.INTEGER(), autoincrement=False, nullable=False),
- sa.Column('file_id', sa.INTEGER(), autoincrement=False, nullable=False),
- sa.ForeignKeyConstraint(['file_id'], ['file.id'], name='page_file_file_id_fkey'),
- sa.ForeignKeyConstraint(['page_id'], ['page.id'], name='page_file_page_id_fkey'),
- sa.PrimaryKeyConstraint('page_id', 'file_id', name='page_file_pkey')
- )
- op.drop_table('vote')
- op.drop_table('option')
- op.drop_table('question')
- op.drop_table('ballot')
- op.drop_table('priority')
|