"""Commit

Revision ID: aca5ffb936e3
Revises: 
Create Date: 2021-03-08 23:47:38.106405

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=120), nullable=False),
    sa.Column('username', sa.String(length=64), nullable=False),
    sa.Column('password', sa.String(length=128), nullable=False),
    sa.PrimaryKeyConstraint('id', name=op.f('pk__users')),
    sa.UniqueConstraint('email', name=op.f('uq__users__email')),
    sa.UniqueConstraint('id', name=op.f('uq__users__id')),
    sa.UniqueConstraint('username', name=op.f('uq__users__username'))
    )
    op.create_table('stats',
    sa.Column('game_id', sa.String(length=64), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('game_result', sa.Enum('win', 'lose', 'tie', name='game_result'), nullable=False),
    sa.Column('start_time', sa.DateTime(), nullable=False),
    sa.Column('end_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='fk_user_id'),
    sa.PrimaryKeyConstraint('game_id', name=op.f('pk__stats')),
    sa.UniqueConstraint('game_id', name=op.f('uq__stats__game_id'))
    )
    op.create_table('game_instance',
    sa.Column('game_id', sa.String(length=64), nullable=False),
    sa.Column('move_number', sa.Integer(), nullable=False),
    sa.Column('row', sa.Integer(), nullable=False),
    sa.Column('column', sa.Integer(), nullable=False),
    sa.Column('character', sa.Enum('X', 'O', name='character'), nullable=False),
    sa.ForeignKeyConstraint(['game_id'], ['stats.game_id'], name='fk_game_id'),
    sa.PrimaryKeyConstraint('game_id', name=op.f('pk__game_instance'))
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('game_instance')
    op.drop_table('stats')
    op.drop_table('users')
    # ### end Alembic commands ###
