"""Attempt 3 at hooking runes into the rune choices row, moving runes to the player metadata

Revision ID: 91e2634409cd
Revises: b1286a9da136
Create Date: 2020-02-12 10:38:12.281550

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '91e2634409cd'
down_revision = 'b1286a9da136'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('game_frames_rune_choices_8_fkey', 'game_frames', type_='foreignkey')
    op.drop_constraint('game_frames_rune_choices_3_fkey', 'game_frames', type_='foreignkey')
    op.drop_constraint('game_frames_rune_choices_7_fkey', 'game_frames', type_='foreignkey')
    op.drop_constraint('game_frames_rune_choices_2_fkey', 'game_frames', type_='foreignkey')
    op.drop_constraint('game_frames_rune_choices_5_fkey', 'game_frames', type_='foreignkey')
    op.drop_constraint('game_frames_rune_choices_6_fkey', 'game_frames', type_='foreignkey')
    op.drop_constraint('game_frames_rune_choices_1_fkey', 'game_frames', type_='foreignkey')
    op.drop_constraint('game_frames_rune_choices_4_fkey', 'game_frames', type_='foreignkey')
    op.drop_column('game_frames', 'rune_choices_8')
    op.drop_column('game_frames', 'rune_choices_6')
    op.drop_column('game_frames', 'rune_choices_4')
    op.drop_column('game_frames', 'rune_choices_1')
    op.drop_column('game_frames', 'rune_choices_7')
    op.drop_column('game_frames', 'rune_choices_5')
    op.drop_column('game_frames', 'rune_choices_3')
    op.drop_column('game_frames', 'rune_choices_2')
    op.add_column('game_player_metadata', sa.Column('main_rune', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_1', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_2', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_3', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_4', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_5', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_6', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_7', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_8', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('rune_choices_9', sa.Integer(), nullable=True))
    op.add_column('game_player_metadata', sa.Column('second_rune', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_4'], ['id'])
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_6'], ['id'])
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_9'], ['id'])
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_5'], ['id'])
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_7'], ['id'])
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_3'], ['id'])
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_2'], ['id'])
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_8'], ['id'])
    op.create_foreign_key(None, 'game_player_metadata', 'runes_lookup', ['rune_choices_1'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_constraint(None, 'game_player_metadata', type_='foreignkey')
    op.drop_column('game_player_metadata', 'second_rune')
    op.drop_column('game_player_metadata', 'rune_choices_9')
    op.drop_column('game_player_metadata', 'rune_choices_8')
    op.drop_column('game_player_metadata', 'rune_choices_7')
    op.drop_column('game_player_metadata', 'rune_choices_6')
    op.drop_column('game_player_metadata', 'rune_choices_5')
    op.drop_column('game_player_metadata', 'rune_choices_4')
    op.drop_column('game_player_metadata', 'rune_choices_3')
    op.drop_column('game_player_metadata', 'rune_choices_2')
    op.drop_column('game_player_metadata', 'rune_choices_1')
    op.drop_column('game_player_metadata', 'main_rune')
    op.add_column('game_frames', sa.Column('rune_choices_2', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('game_frames', sa.Column('rune_choices_3', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('game_frames', sa.Column('rune_choices_5', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('game_frames', sa.Column('rune_choices_7', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('game_frames', sa.Column('rune_choices_1', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('game_frames', sa.Column('rune_choices_4', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('game_frames', sa.Column('rune_choices_6', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('game_frames', sa.Column('rune_choices_8', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('game_frames_rune_choices_4_fkey', 'game_frames', 'runes_lookup', ['rune_choices_4'], ['id'])
    op.create_foreign_key('game_frames_rune_choices_1_fkey', 'game_frames', 'runes_lookup', ['rune_choices_1'], ['id'])
    op.create_foreign_key('game_frames_rune_choices_6_fkey', 'game_frames', 'runes_lookup', ['rune_choices_6'], ['id'])
    op.create_foreign_key('game_frames_rune_choices_5_fkey', 'game_frames', 'runes_lookup', ['rune_choices_5'], ['id'])
    op.create_foreign_key('game_frames_rune_choices_2_fkey', 'game_frames', 'runes_lookup', ['rune_choices_2'], ['id'])
    op.create_foreign_key('game_frames_rune_choices_7_fkey', 'game_frames', 'runes_lookup', ['rune_choices_7'], ['id'])
    op.create_foreign_key('game_frames_rune_choices_3_fkey', 'game_frames', 'runes_lookup', ['rune_choices_3'], ['id'])
    op.create_foreign_key('game_frames_rune_choices_8_fkey', 'game_frames', 'runes_lookup', ['rune_choices_8'], ['id'])
    # ### end Alembic commands ###
