"""empty message

Revision ID: 8bba9527a87e
Revises: 
Create Date: 2020-10-03 17:43:45.572634

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8bba9527a87e'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('artists', 'age',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('artists', 'gender',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('artists', 'name',
               existing_type=sa.TEXT(),
               nullable=True)
    op.drop_constraint('artist_id', 'moviecast', type_='foreignkey')
    op.drop_constraint('movie_id', 'moviecast', type_='foreignkey')
    op.create_foreign_key(None, 'moviecast', 'artists', ['artist_id'], ['id'])
    op.create_foreign_key(None, 'moviecast', 'movies', ['movie_id'], ['id'])
    op.alter_column('movies', 'release_date',
               existing_type=sa.DATE(),
               nullable=True)
    op.alter_column('movies', 'title',
               existing_type=sa.TEXT(),
               nullable=True)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('movies', 'title',
               existing_type=sa.TEXT(),
               nullable=False)
    op.alter_column('movies', 'release_date',
               existing_type=sa.DATE(),
               nullable=False)
    op.drop_constraint(None, 'moviecast', type_='foreignkey')
    op.drop_constraint(None, 'moviecast', type_='foreignkey')
    op.create_foreign_key('movie_id', 'moviecast', 'movies', ['movie_id'], ['id'], onupdate='CASCADE', ondelete='SET NULL')
    op.create_foreign_key('artist_id', 'moviecast', 'artists', ['artist_id'], ['id'], onupdate='CASCADE', ondelete='SET NULL')
    op.alter_column('artists', 'name',
               existing_type=sa.TEXT(),
               nullable=False)
    op.alter_column('artists', 'gender',
               existing_type=sa.TEXT(),
               nullable=False)
    op.alter_column('artists', 'age',
               existing_type=sa.INTEGER(),
               nullable=False)
    # ### end Alembic commands ###
