"""create application_type table and update submission window

Revision ID: bab396e50b1f
Revises: 0ca75433c435
Create Date: 2017-08-03 14:45:39.186161

"""

# revision identifiers, used by Alembic.
revision = 'bab396e50b1f'
down_revision = '0ca75433c435'
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('application_type',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('application_type_id', sa.Integer(), nullable=False),
    sa.Column('application_name', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('application_type_id')
    )
    op.add_column('submission_window', sa.Column('application_type_id', sa.Integer(), nullable=True))
    op.create_foreign_key('fk_submission_window_application', 'submission_window', 'application_type', ['application_type_id'], ['application_type_id'])
    ### end Alembic commands ###


def downgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('fk_submission_window_application', 'submission_window', type_='foreignkey')
    op.drop_column('submission_window', 'application_type_id')
    op.drop_table('application_type')
    ### end Alembic commands ###

