"""coupon table

Revision ID: f3aa57777025
Revises: 96f851cbab01
Create Date: 2020-07-27 10:11:58.760190

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f3aa57777025'
down_revision = '96f851cbab01'
branch_labels = None
depends_on = None

from make_post_sell.models.meta import UUIDType


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('mps_coupon',
    sa.Column('id', UUIDType, nullable=False),
    sa.Column('shop_id', UUIDType, nullable=False),
    sa.Column('code', sa.Unicode(length=256), nullable=False),
    sa.Column('description', sa.Unicode(length=256), nullable=False),
    sa.Column('action_type', sa.Enum('percent-off', 'dollar-off', name='action_type'), nullable=False),
    sa.Column('action_value', sa.BigInteger(), nullable=False),
    sa.Column('redemptions', sa.BigInteger(), nullable=False),
    sa.Column('max_redemptions', sa.BigInteger(), nullable=True),
    sa.Column('max_redemptions_per_user', sa.BigInteger(), nullable=True),
    sa.Column('cart_qualifier', sa.BigInteger(), nullable=True),
    sa.Column('created_timestamp', sa.BigInteger(), nullable=False),
    sa.Column('expired_timestamp', sa.BigInteger(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['shop_id'], ['mps_shop.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_mps_coupon_id'), 'mps_coupon', ['id'], unique=False)


def downgrade():
    op.drop_index(op.f('ix_mps_coupon_id'), table_name='mps_coupon')
    op.drop_table('mps_coupon')
