"""Remove legacy task order table

Revision ID: fb22e47972a3
Revises: 978bf56e21b6
Create Date: 2019-02-20 18:28:56.386152

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'fb22e47972a3'
down_revision = '978bf56e21b6'
branch_labels = None
depends_on = None


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


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('legacy_task_orders',
    sa.Column('time_created', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=False),
    sa.Column('time_updated', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=False),
    sa.Column('id', postgresql.UUID(), server_default=sa.text('uuid_generate_v4()'), autoincrement=False, nullable=False),
    sa.Column('number', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('source', sa.VARCHAR(length=6), autoincrement=False, nullable=True),
    sa.Column('funding_type', sa.VARCHAR(length=5), autoincrement=False, nullable=True),
    sa.Column('funding_type_other', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('clin_0001', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('clin_0003', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('clin_1001', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('clin_1003', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('clin_2001', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('clin_2003', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('expiration_date', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('attachment_id', postgresql.UUID(), autoincrement=False, nullable=True),
    sa.CheckConstraint("(funding_type)::text = ANY ((ARRAY['RDTE'::character varying, 'OM'::character varying, 'PROC'::character varying, 'OTHER'::character varying])::text[])", name='fundingtype'),
    sa.CheckConstraint("(source)::text = ANY ((ARRAY['MANUAL'::character varying, 'EDA'::character varying])::text[])", name='source'),
    sa.ForeignKeyConstraint(['attachment_id'], ['attachments.id'], name='task_orders_attachment_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='task_orders_pkey'),
    sa.UniqueConstraint('number', name='task_orders_number_key')
    )
    # ### end Alembic commands ###
