"""empty message

Revision ID: 88162422f489
Revises: 
Create Date: 2020-10-25 02:28:49.305303

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '88162422f489'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('user_products_product_id_fkey', 'user_products', type_='foreignkey')
    op.drop_constraint('user_products_user_id_fkey', 'user_products', type_='foreignkey')
    op.create_foreign_key(None, 'user_products', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
    op.create_foreign_key(None, 'user_products', 'products', ['product_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
    op.alter_column('users', 'first_name',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.alter_column('users', 'last_name',
               existing_type=sa.VARCHAR(),
               nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('users', 'last_name',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.alter_column('users', 'first_name',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.drop_constraint(None, 'user_products', type_='foreignkey')
    op.drop_constraint(None, 'user_products', type_='foreignkey')
    op.create_foreign_key('user_products_user_id_fkey', 'user_products', 'users', ['user_id'], ['id'])
    op.create_foreign_key('user_products_product_id_fkey', 'user_products', 'products', ['product_id'], ['id'])
    # ### end Alembic commands ###
