"""Add time-based achievements.

Revision ID: 2a3ebcd7d840
Revises: bc7d717a37d6
Create Date: 2017-04-27 16:28:15.365526

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2a3ebcd7d840'
down_revision = 'bc7d717a37d6'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('time_based_achievement',
    sa.Column('refid', sa.String(length=16), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('type', sa.String(length=64), nullable=False),
    sa.Column('timestamp', sa.Integer(), nullable=False),
    sa.Column('data', sa.JSON(), nullable=False),
    sa.UniqueConstraint('refid', 'id', 'type', 'timestamp', name='refid_id_type_timestamp'),
    mysql_charset='utf8mb4'
    )
    op.create_index(op.f('ix_time_based_achievement_timestamp'), 'time_based_achievement', ['timestamp'], unique=False)
    # ### end Alembic commands ###


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