"""3rd update that adds Games table with API_KEY and backref on scores

Revision ID: 37a45401820b
Revises: 3414dfab0e91
Create Date: 2015-11-01 15:07:23.655544

"""

# revision identifiers, used by Alembic.
revision = '37a45401820b'
down_revision = '3414dfab0e91'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('games',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('api_key', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('api_key')
    )
    op.add_column(u'scores', sa.Column('game_id', sa.Integer(), nullable=False))
    op.create_foreign_key(None, 'scores', 'games', ['game_id'], ['id'])
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'scores', type_='foreignkey')
    op.drop_column(u'scores', 'game_id')
    op.drop_table('games')
    ### end Alembic commands ###
