"""add dice table

Revision ID: 04e1b9d2bec8
Revises: fc8098eea2d6
Create Date: 2019-01-17 11:47:17.959727

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = '04e1b9d2bec8'
down_revision = 'fc8098eea2d6'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('dice_config',
    sa.Column('_id', sa.BigInteger(), autoincrement=True, nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default='0000-00-00 00:00:00', nullable=False),
    sa.Column('update_at', sa.DateTime(), server_default='0000-00-00 00:00:00', nullable=False),
    sa.Column('deleted_at', sa.DateTime(), server_default='0000-00-00 00:00:00', nullable=False),
    sa.Column('deleted', sa.Boolean(), server_default='0', nullable=False),
    sa.Column('support_token_id', mysql.INTEGER(), server_default='-1', nullable=False),
    sa.Column('support_token_name', sa.String(length=64), server_default='', nullable=False),
    sa.Column('default_bet_volume', sa.Numeric(precision=21, scale=4), server_default='0.0000', nullable=False),
    sa.Column('lower_bet_volume', sa.Numeric(precision=21, scale=4), server_default='0.0000', nullable=False),
    sa.Column('ceiling_bet_volume', sa.Numeric(precision=21, scale=4), server_default='0.0000', nullable=False),
    sa.Column('handling_fee', mysql.INTEGER(), server_default='0', nullable=False),
    sa.Column('status', mysql.TINYINT(), server_default='0', nullable=False),
    sa.PrimaryKeyConstraint('_id')
    )
    op.create_table('dice_participate_in',
    sa.Column('_id', sa.BigInteger(), autoincrement=True, nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default='0000-00-00 00:00:00', nullable=False),
    sa.Column('update_at', sa.DateTime(), server_default='0000-00-00 00:00:00', nullable=False),
    sa.Column('deleted_at', sa.DateTime(), server_default='0000-00-00 00:00:00', nullable=False),
    sa.Column('deleted', sa.Boolean(), server_default='0', nullable=False),
    sa.Column('dice_serial', sa.String(length=64), server_default='', nullable=False),
    sa.Column('user_id', sa.String(length=64), server_default='', nullable=False),
    sa.Column('user_dice', mysql.TINYINT(), server_default='-1', nullable=False),
    sa.Column('banker_dice', mysql.TINYINT(), server_default='-1', nullable=False),
    sa.Column('channel', sa.String(length=64), server_default='', nullable=False),
    sa.Column('bet_number', sa.Numeric(precision=21, scale=4), server_default='0.0000', nullable=False),
    sa.Column('bet_token', mysql.INTEGER(), server_default='0', nullable=False),
    sa.Column('reward_token', mysql.INTEGER(), server_default='0', nullable=False),
    sa.Column('reward_quantity', sa.Numeric(precision=21, scale=4), server_default='0.0000', nullable=False),
    sa.Column('dice_result', mysql.TINYINT(), server_default='-1', nullable=False),
    sa.Column('dice_timestamp', sa.String(length=255), server_default='0000-00-00T00:00:00.000', nullable=False),
    sa.Column('block_timestamp', sa.String(length=255), server_default='0000-00-00T00:00:00.000', nullable=False),
    sa.Column('block_no', mysql.INTEGER(), server_default='0', nullable=False),
    sa.PrimaryKeyConstraint('_id'),
    sa.UniqueConstraint('dice_serial')
    )
    # ### end Alembic commands ###


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