"""empty message

Revision ID: 7f2469230c74
Revises: 4eefb01ed3f2
Create Date: 2019-01-24 09:19:30.229384

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '7f2469230c74'
down_revision = '4eefb01ed3f2'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('hall_ibfk_1', 'hall', type_='foreignkey')
    op.create_foreign_key(None, 'hall', 'cinema', ['cid'], ['cid'])
    op.drop_constraint('hall_scheduling_ibfk_3', 'hall_scheduling', type_='foreignkey')
    op.drop_constraint('hall_scheduling_ibfk_1', 'hall_scheduling', type_='foreignkey')
    op.drop_constraint('hall_scheduling_ibfk_2', 'hall_scheduling', type_='foreignkey')
    op.create_foreign_key(None, 'hall_scheduling', 'cinema', ['cinema_id'], ['cid'])
    op.create_foreign_key(None, 'hall_scheduling', 'hall', ['hall_id'], ['hid'])
    op.create_foreign_key(None, 'hall_scheduling', 'movie', ['movie_id'], ['id'])
    op.drop_constraint('order_ibfk_5', 'order', type_='foreignkey')
    op.drop_constraint('order_ibfk_4', 'order', type_='foreignkey')
    op.drop_constraint('order_ibfk_1', 'order', type_='foreignkey')
    op.drop_constraint('order_ibfk_3', 'order', type_='foreignkey')
    op.drop_constraint('order_ibfk_2', 'order', type_='foreignkey')
    op.create_foreign_key(None, 'order', 'seats', ['seat_id'], ['sid'])
    op.create_foreign_key(None, 'order', 'movie', ['movie_id'], ['id'])
    op.create_foreign_key(None, 'order', 'seat_scheduling', ['ss_id'], ['id'])
    op.create_foreign_key(None, 'order', 'hall_scheduling', ['hs_id'], ['hsid'])
    op.create_foreign_key(None, 'order', 'cinema', ['cinema_id'], ['cid'])
    op.drop_constraint('rating_ibfk_1', 'rating', type_='foreignkey')
    op.create_foreign_key(None, 'rating', 'movie', ['movie_id'], ['id'])
    op.drop_constraint('seat_scheduling_ibfk_2', 'seat_scheduling', type_='foreignkey')
    op.drop_constraint('seat_scheduling_ibfk_3', 'seat_scheduling', type_='foreignkey')
    op.drop_constraint('seat_scheduling_ibfk_1', 'seat_scheduling', type_='foreignkey')
    op.create_foreign_key(None, 'seat_scheduling', 'seats', ['seat_id'], ['sid'])
    op.create_foreign_key(None, 'seat_scheduling', 'hall', ['hall_id'], ['hid'])
    op.create_foreign_key(None, 'seat_scheduling', 'hall_scheduling', ['hs_id'], ['hsid'])
    op.drop_constraint('seats_ibfk_1', 'seats', type_='foreignkey')
    op.drop_constraint('seats_ibfk_2', 'seats', type_='foreignkey')
    op.create_foreign_key(None, 'seats', 'cinema', ['cid'], ['cid'])
    op.create_foreign_key(None, 'seats', 'hall', ['hid'], ['hid'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'seats', type_='foreignkey')
    op.drop_constraint(None, 'seats', type_='foreignkey')
    op.create_foreign_key('seats_ibfk_2', 'seats', 'hall', ['hid'], ['hid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('seats_ibfk_1', 'seats', 'cinema', ['cid'], ['cid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.drop_constraint(None, 'seat_scheduling', type_='foreignkey')
    op.drop_constraint(None, 'seat_scheduling', type_='foreignkey')
    op.drop_constraint(None, 'seat_scheduling', type_='foreignkey')
    op.create_foreign_key('seat_scheduling_ibfk_1', 'seat_scheduling', 'hall', ['hall_id'], ['hid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('seat_scheduling_ibfk_3', 'seat_scheduling', 'seats', ['seat_id'], ['sid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('seat_scheduling_ibfk_2', 'seat_scheduling', 'hall_scheduling', ['hs_id'], ['hsid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.drop_constraint(None, 'rating', type_='foreignkey')
    op.create_foreign_key('rating_ibfk_1', 'rating', 'movie', ['movie_id'], ['id'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.drop_constraint(None, 'order', type_='foreignkey')
    op.drop_constraint(None, 'order', type_='foreignkey')
    op.drop_constraint(None, 'order', type_='foreignkey')
    op.drop_constraint(None, 'order', type_='foreignkey')
    op.drop_constraint(None, 'order', type_='foreignkey')
    op.create_foreign_key('order_ibfk_2', 'order', 'hall_scheduling', ['hs_id'], ['hsid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('order_ibfk_3', 'order', 'movie', ['movie_id'], ['id'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('order_ibfk_1', 'order', 'cinema', ['cinema_id'], ['cid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('order_ibfk_4', 'order', 'seats', ['seat_id'], ['sid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('order_ibfk_5', 'order', 'seat_scheduling', ['ss_id'], ['id'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.drop_constraint(None, 'hall_scheduling', type_='foreignkey')
    op.drop_constraint(None, 'hall_scheduling', type_='foreignkey')
    op.drop_constraint(None, 'hall_scheduling', type_='foreignkey')
    op.create_foreign_key('hall_scheduling_ibfk_2', 'hall_scheduling', 'hall', ['hall_id'], ['hid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('hall_scheduling_ibfk_1', 'hall_scheduling', 'cinema', ['cinema_id'], ['cid'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.create_foreign_key('hall_scheduling_ibfk_3', 'hall_scheduling', 'movie', ['movie_id'], ['id'], onupdate='RESTRICT', ondelete='RESTRICT')
    op.drop_constraint(None, 'hall', type_='foreignkey')
    op.create_foreign_key('hall_ibfk_1', 'hall', 'cinema', ['cid'], ['cid'], onupdate='RESTRICT', ondelete='RESTRICT')
    # ### end Alembic commands ###
