"""Create play session table.

Revision ID: 56dd21b994fe
Revises: 8666c2253770
Create Date: 2017-12-04 21:47:30.701495

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '56dd21b994fe'
down_revision = '8666c2253770'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('playsession',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('game', sa.String(length=32), nullable=False),
    sa.Column('version', sa.Integer(), nullable=False),
    sa.Column('userid', sa.Integer(), nullable=False),
    sa.Column('time', sa.Integer(), nullable=False),
    sa.Column('data', sa.JSON(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('game', 'version', 'userid', name='game_version_userid'),
    mysql_charset='utf8mb4'
    )
    op.create_index(op.f('ix_playsession_time'), 'playsession', ['time'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_playsession_time'), table_name='playsession')
    op.drop_table('playsession')
    # ### end Alembic commands ###
