"""add_publish_status

Revision ID: 1f5613e38200
Revises: c2b6d88e6d44
Create Date: 2016-08-04 13:49:32.364079

"""

# revision identifiers, used by Alembic.
revision = '1f5613e38200'
down_revision = 'c2b6d88e6d44'
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('publish_status',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('publish_status_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.Text(), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('publish_status_id')
    )
    op.add_column('submission', sa.Column('number_of_errors', sa.Integer(), nullable=True))
    op.add_column('submission', sa.Column('number_of_warnings', sa.Integer(), nullable=True))
    op.add_column('submission', sa.Column('publish_status_id', sa.Integer(), nullable=True))
    op.add_column('submission', sa.Column('publishable', sa.Boolean(), server_default='False', nullable=False))
    op.create_foreign_key('fk_publish_status_id', 'submission', 'publish_status', ['publish_status_id'], ['publish_status_id'], ondelete='CASCADE')
    ### end Alembic commands ###


def downgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('fk_publish_status_id', 'submission', type_='foreignkey')
    op.drop_column('submission', 'publishable')
    op.drop_column('submission', 'publish_status_id')
    op.drop_column('submission', 'number_of_warnings')
    op.drop_column('submission', 'number_of_errors')
    op.drop_table('publish_status')
    ### end Alembic commands ###

