"""add d file metadata table

Revision ID: 6f5c2c66b328
Revises: 65ce5d505f12
Create Date: 2016-08-02 13:57:44.000353

"""

# revision identifiers, used by Alembic.
revision = '6f5c2c66b328'
down_revision = '65ce5d505f12'
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('d_file_metadata',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('d_file_id', sa.Integer(), nullable=False),
    sa.Column('type', sa.Text(), nullable=True),
    sa.Column('submission_id', sa.Integer(), nullable=True),
    sa.Column('start_date', sa.Date(), nullable=True),
    sa.Column('end_date', sa.Date(), nullable=True),
    sa.Column('status_id', sa.Integer(), nullable=True),
    sa.Column('url', sa.Text(), nullable=True),
    sa.Column('error_message', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['status_id'], ['job_status.job_status_id'], name='fk_status_id'),
    sa.ForeignKeyConstraint(['submission_id'], ['submission.submission_id'], name='fk_submission_id'),
    sa.PrimaryKeyConstraint('d_file_id'),
    sa.UniqueConstraint('submission_id', 'type', name='_submission_type_uc')
    )
    ### end Alembic commands ###


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

