"""empty message

Revision ID: dce20e027f0d
Revises: 82669ff31369
Create Date: 2021-05-06 17:40:49.440681

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

# revision identifiers, used by Alembic.
revision = 'dce20e027f0d'
down_revision = '82669ff31369'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('genres',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('name', sa.VARCHAR(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('movies',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('title', sa.VARCHAR(length=255), nullable=False),
    sa.Column('plot', sa.TEXT(), nullable=True),
    sa.Column('imdb_rating', sa.DECIMAL(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('persons',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('name', sa.VARCHAR(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('movies_genres',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('movie_id', postgresql.UUID(as_uuid=True), nullable=True),
    sa.Column('genre_id', postgresql.UUID(as_uuid=True), nullable=True),
    sa.ForeignKeyConstraint(['genre_id'], ['genres.id'], ),
    sa.ForeignKeyConstraint(['movie_id'], ['movies.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('movies_person',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('movie_id', postgresql.UUID(as_uuid=True), nullable=True),
    sa.Column('person_id', postgresql.UUID(as_uuid=True), nullable=True),
    sa.Column('position', sa.Enum('DIRECTOR', 'WRITER', 'ACTOR', name='personposition'), nullable=True),
    sa.ForeignKeyConstraint(['movie_id'], ['movies.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['persons.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('movies_person')
    op.drop_table('movies_genres')
    op.drop_table('persons')
    op.drop_table('movies')
    op.drop_table('genres')
    # ### end Alembic commands ###
