"""Remove not needed entities

Revision ID: 2fda8ca68cbf
Revises: ccb46e8d0df5
Create Date: 2020-12-06 16:40:49.986244

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

# revision identifiers, used by Alembic.
revision = '2fda8ca68cbf'
down_revision = 'ccb46e8d0df5'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('occupied_seats')
    op.drop_constraint('schedules_ibfk_1', 'schedules', type_='foreignkey')
    op.drop_column('schedules', 'hall_id')
    op.drop_table('halls')
    op.drop_column('users', 'role')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('role', mysql.VARCHAR(length=25), nullable=False))
    op.add_column('schedules', sa.Column('hall_id', mysql.VARCHAR(length=36), nullable=False))
    op.create_foreign_key('schedules_ibfk_1', 'schedules', 'halls', ['hall_id'], ['id'])
    op.create_table('halls',
    sa.Column('id', mysql.VARCHAR(length=36), nullable=False),
    sa.Column('occupancy_of_hall', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset='utf8',
    mysql_engine='InnoDB'
    )
    op.create_table('occupied_seats',
    sa.Column('id', mysql.VARCHAR(length=36), nullable=False),
    sa.Column('user_id', mysql.VARCHAR(length=36), nullable=False),
    sa.Column('film_ocupation_time_id', mysql.VARCHAR(length=36), nullable=False),
    sa.ForeignKeyConstraint(['film_ocupation_time_id'], ['film_occupations_times.id'], name='occupied_seats_ibfk_1'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='occupied_seats_ibfk_2'),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset='utf8',
    mysql_engine='InnoDB'
    )
    # ### end Alembic commands ###
