"""game table; opening table

Revision ID: 23bf5929695f
Revises: 
Create Date: 2019-10-07 12:44:32.423744

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '23bf5929695f'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('opening',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('eco_code', sa.String(length=4), nullable=True),
    sa.Column('name', sa.String(length=128), nullable=True),
    sa.Column('moves', sa.String(length=256), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_opening_eco_code'), 'opening', ['eco_code'], unique=False)
    op.create_index(op.f('ix_opening_moves'), 'opening', ['moves'], unique=False)
    op.create_index(op.f('ix_opening_name'), 'opening', ['name'], unique=False)
    op.create_table('game',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('pgn', sa.String(), nullable=True),
    sa.Column('white_player', sa.String(length=64), nullable=True),
    sa.Column('black_player', sa.String(length=64), nullable=True),
    sa.Column('date', sa.Date(), nullable=True),
    sa.Column('opening_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['opening_id'], ['opening.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_game_black_player'), 'game', ['black_player'], unique=False)
    op.create_index(op.f('ix_game_date'), 'game', ['date'], unique=False)
    op.create_index(op.f('ix_game_pgn'), 'game', ['pgn'], unique=True)
    op.create_index(op.f('ix_game_white_player'), 'game', ['white_player'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_game_white_player'), table_name='game')
    op.drop_index(op.f('ix_game_pgn'), table_name='game')
    op.drop_index(op.f('ix_game_date'), table_name='game')
    op.drop_index(op.f('ix_game_black_player'), table_name='game')
    op.drop_table('game')
    op.drop_index(op.f('ix_opening_name'), table_name='opening')
    op.drop_index(op.f('ix_opening_moves'), table_name='opening')
    op.drop_index(op.f('ix_opening_eco_code'), table_name='opening')
    op.drop_table('opening')
    # ### end Alembic commands ###
