"""Added the 'scenario' tables.

Revision ID: e77d4e8d37f3
Revises: 23e928dda837
Create Date: 2019-12-20 09:46:35.304849

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'e77d4e8d37f3'
down_revision = '23e928dda837'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('scenario',
    sa.Column('scenario_id', sa.Integer(), nullable=False),
    sa.Column('scenario_roar_id', sa.String(length=50), nullable=True),
    sa.Column('scenario_display_id', sa.String(length=50), nullable=True),
    sa.Column('scenario_name', sa.String(length=200), nullable=False),
    sa.PrimaryKeyConstraint('scenario_id'),
    sa.UniqueConstraint('scenario_roar_id', 'scenario_display_id', 'scenario_name', name='unq_id_name')
    )
    op.create_table('article_scenario',
    sa.Column('article_scenario_id', sa.Integer(), nullable=False),
    sa.Column('seq_no', sa.Integer(), nullable=False),
    sa.Column('article_id', sa.Integer(), nullable=False),
    sa.Column('scenario_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['article_id'], ['article.article_id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['scenario_id'], ['scenario.scenario_id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('article_scenario_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('article_scenario')
    op.drop_table('scenario')
    # ### end Alembic commands ###
