"""empty message

Revision ID: 0fd05ce2c513
Revises: 
Create Date: 2020-11-20 13:17:44.178490

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

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_customer_email', table_name='customer')
    op.drop_table('customer')
    op.add_column('cart', sa.Column('user_id', sa.Integer(), nullable=True))
    op.drop_constraint('cart_customer_id_fkey', 'cart', type_='foreignkey')
    op.create_foreign_key(None, 'cart', 'user', ['user_id'], ['id'])
    op.drop_column('cart', 'customer_id')
    op.add_column('user', sa.Column('is_customer', sa.Boolean(), nullable=True))
    op.drop_constraint('user_customer_id_fkey', 'user', type_='foreignkey')
    op.drop_column('user', 'customer_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('customer_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.create_foreign_key('user_customer_id_fkey', 'user', 'customer', ['customer_id'], ['customer_id'])
    op.drop_column('user', 'is_customer')
    op.add_column('cart', sa.Column('customer_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cart', type_='foreignkey')
    op.create_foreign_key('cart_customer_id_fkey', 'cart', 'customer', ['customer_id'], ['customer_id'])
    op.drop_column('cart', 'user_id')
    op.create_table('customer',
    sa.Column('customer_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('first_name', sa.VARCHAR(length=50), autoincrement=False, nullable=True),
    sa.Column('last_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('email', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('created_on', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('customer_id', name='customer_pkey')
    )
    op.create_index('ix_customer_email', 'customer', ['email'], unique=True)
    # ### end Alembic commands ###
