"""Add narrative table

Revision ID: e2aef4260e1f
Revises: a57a6a486f83
Create Date: 2016-11-17 22:24:36.546851

"""

# revision identifiers, used by Alembic.
revision = 'e2aef4260e1f'
down_revision = 'a57a6a486f83'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()





def upgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('submission_narrative',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('submission_narrative_id', sa.Integer(), nullable=False),
    sa.Column('submission_id', sa.Integer(), nullable=False),
    sa.Column('file_type_id', sa.Integer(), nullable=False),
    sa.Column('narrative', sa.Text(), nullable=False),
    sa.ForeignKeyConstraint(['file_type_id'], ['file_type.file_type_id'], name='fk_file_type'),
    sa.ForeignKeyConstraint(['submission_id'], ['submission.submission_id'], name='fk_submission'),
    sa.PrimaryKeyConstraint('submission_narrative_id'),
    sa.UniqueConstraint('submission_id', 'file_type_id', name='uniq_submission_file_type')
    )
    ### end Alembic commands ###


def downgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('submission_narrative')
    ### end Alembic commands ###

