"""Add BusinessModel

Revision ID: f4af9a0e8e07
Revises: 869d4f824bd7
Create Date: 2021-07-21 07:32:38.294111

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f4af9a0e8e07'
down_revision = '869d4f824bd7'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('businesses',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('business_name', sa.String(length=50), nullable=True),
    sa.Column('email', sa.String(length=50), nullable=True),
    sa.Column('password', sa.String(length=50), nullable=True),
    sa.Column('username', sa.String(length=20), nullable=False),
    sa.Column('bio', sa.String(length=200), nullable=True),
    sa.Column('creation_date', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_businesses')),
    sa.UniqueConstraint('business_name', name=op.f('uq_businesses_business_name'))
    )
    op.create_index(op.f('ix_businesses_username'), 'businesses', ['username'], unique=False)
    op.add_column('confirmations', sa.Column('client_id', sa.Integer()))
    op.add_column('confirmations', sa.Column('business_id', sa.Integer()))
    op.drop_constraint('fk_confirmations_user_id_clients', 'confirmations', type_='foreignkey')
    op.create_foreign_key(op.f('fk_confirmations_business_id_businesses'), 'confirmations', 'businesses', ['business_id'], ['id'])
    op.create_foreign_key(op.f('fk_confirmations_client_id_clients'), 'confirmations', 'clients', ['client_id'], ['id'])
    op.drop_column('confirmations', 'user_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('confirmations', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False))
    op.drop_constraint(op.f('fk_confirmations_client_id_clients'), 'confirmations', type_='foreignkey')
    op.drop_constraint(op.f('fk_confirmations_business_id_businesses'), 'confirmations', type_='foreignkey')
    op.create_foreign_key('fk_confirmations_user_id_clients', 'confirmations', 'clients', ['user_id'], ['id'])
    op.drop_column('confirmations', 'business_id')
    op.drop_column('confirmations', 'client_id')
    op.drop_index(op.f('ix_businesses_username'), table_name='businesses')
    op.drop_table('businesses')
    # ### end Alembic commands ###
