"""Remove request related models

Revision ID: c92cec2f32d4
Revises: 3777e9e39644
Create Date: 2019-02-20 17:37:33.992269

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

# revision identifiers, used by Alembic.
revision = 'c92cec2f32d4'
down_revision = '3777e9e39644'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('request_status_events')
    op.drop_table('request_reviews')
    op.drop_table('request_internal_comments')
    op.drop_table('request_revisions')
    op.drop_index('ix_audit_events_request_id', table_name='audit_events')
    op.drop_constraint('audit_events_request_id_fkey', 'audit_events', type_='foreignkey')
    op.drop_column('audit_events', 'request_id')
    op.drop_constraint('workspaces_request_id_fkey', 'portfolios', type_='foreignkey')
    op.drop_table('requests')
    op.drop_column('portfolios', 'request_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('portfolios', sa.Column('request_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('audit_events', sa.Column('request_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.create_table('requests',
    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('time_created', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True),
    sa.Column('user_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('legacy_task_order_id', postgresql.UUID(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['legacy_task_order_id'], ['legacy_task_orders.id'], name='requests_legacy_task_order_fkey'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='requests_user_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='requests_pkey'),
    postgresql_ignore_search_path=False
    )
    op.create_index('ix_audit_events_request_id', 'audit_events', ['request_id'], unique=False)
    op.create_table('request_revisions',
    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('request_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('sequence', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('am_poc', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('dodid_poc', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('email_poc', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('fname_poc', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('lname_poc', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('jedi_usage', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('start_date', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('cloud_native', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('dollar_value', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('dod_component', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('data_transfers', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('expected_completion_date', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('jedi_migration', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('num_software_systems', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('number_user_sessions', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('average_daily_traffic', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('engineering_assessment', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('technical_support_team', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('estimated_monthly_spend', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('average_daily_traffic_gb', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('rationalization_software_systems', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('organization_providing_assistance', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('citizenship', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('designation', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('phone_number', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('email_request', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('fname_request', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('lname_request', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('service_branch', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('date_latest_training', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('pe_id', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('task_order_number', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('fname_co', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('lname_co', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('email_co', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('office_co', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('fname_cor', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('lname_cor', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('email_cor', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('office_cor', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('uii_ids', postgresql.ARRAY(sa.VARCHAR()), autoincrement=False, nullable=True),
    sa.Column('treasury_code', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('ba_code', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('phone_ext', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['request_id'], ['requests.id'], name='request_revisions_request_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='request_revisions_pkey'),
    postgresql_ignore_search_path=False
    )
    op.create_table('request_internal_comments',
    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('text', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('user_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('request_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['request_id'], ['requests.id'], name='request_internal_comments_request_id_fkey', ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='request_internal_comments_user_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='request_internal_comments_pkey')
    )
    op.create_table('request_reviews',
    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('user_id', postgresql.UUID(), autoincrement=False, nullable=True),
    sa.Column('comment', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('fname_mao', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('lname_mao', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('email_mao', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('phone_mao', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('fname_ccpo', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('lname_ccpo', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('phone_ext_mao', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='request_reviews_user_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='request_reviews_pkey'),
    postgresql_ignore_search_path=False
    )
    op.create_table('request_status_events',
    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('new_status', sa.VARCHAR(length=30), autoincrement=False, nullable=True),
    sa.Column('time_created', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=False),
    sa.Column('request_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('sequence', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('request_revision_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('request_review_id', postgresql.UUID(), autoincrement=False, nullable=True),
    sa.CheckConstraint("(new_status)::text = ANY ((ARRAY['STARTED'::character varying, 'SUBMITTED'::character varying, 'PENDING_FINANCIAL_VERIFICATION'::character varying, 'PENDING_CCPO_ACCEPTANCE'::character varying, 'PENDING_CCPO_APPROVAL'::character varying, 'CHANGES_REQUESTED'::character varying, 'CHANGES_REQUESTED_TO_FINVER'::character varying, 'APPROVED'::character varying, 'EXPIRED'::character varying, 'DELETED'::character varying])::text[])", name='requeststatus'),
    sa.ForeignKeyConstraint(['request_id'], ['requests.id'], name='request_status_events_request_id_fkey', ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['request_review_id'], ['request_reviews.id'], name='request_status_events_request_review_id_fkey'),
    sa.ForeignKeyConstraint(['request_revision_id'], ['request_revisions.id'], name='request_status_events_request_revision_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='request_status_events_pkey')
    )
    op.create_foreign_key('workspaces_request_id_fkey', 'portfolios', 'requests', ['request_id'], ['id'])
    op.create_foreign_key('audit_events_request_id_fkey', 'audit_events', 'requests', ['request_id'], ['id'])
    # ### end Alembic commands ###
