"""5th update that creates Requests table and adds a backref to game and users

Revision ID: 2b7d1717f5cb
Revises: 32a8ac91d28d
Create Date: 2015-11-09 13:07:07.328317

"""

# revision identifiers, used by Alembic.
revision = '2b7d1717f5cb'
down_revision = '32a8ac91d28d'

from alembic import op
import sqlalchemy as sa


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


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