"""new task order table Revision ID: 6172ac7b8b26 Revises: 1c1394e496a7 Create Date: 2018-12-19 10:00:51.373083 """ from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision = '6172ac7b8b26' down_revision = '1c1394e496a7' branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('task_orders', sa.Column('time_created', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('time_updated', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('workspace_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('scope', sa.String(), nullable=True), sa.Column('defense_component', sa.String(), nullable=True), sa.Column('app_migration', sa.String(), nullable=True), sa.Column('native_apps', sa.String(), nullable=True), sa.Column('complexity', sa.ARRAY(sa.String()), nullable=True), sa.Column('complexity_other', sa.String(), nullable=True), sa.Column('dev_team', sa.ARRAY(sa.String()), nullable=True), sa.Column('dev_team_other', sa.String(), nullable=True), sa.Column('team_experience', sa.String(), nullable=True), sa.Column('start_date', sa.Date(), nullable=True), sa.Column('end_date', sa.Date(), nullable=True), sa.Column('clin_01', sa.Numeric(scale=2), nullable=True), sa.Column('clin_02', sa.Numeric(scale=2), nullable=True), sa.Column('clin_03', sa.Numeric(scale=2), nullable=True), sa.Column('clin_04', sa.Numeric(scale=2), nullable=True), sa.Column('ko_first_name', sa.String(), nullable=True), sa.Column('ko_last_name', sa.String(), nullable=True), sa.Column('ko_email', sa.String(), nullable=True), sa.Column('ko_dod_id', sa.String(), nullable=True), sa.Column('cor_first_name', sa.String(), nullable=True), sa.Column('cor_last_name', sa.String(), nullable=True), sa.Column('cor_email', sa.String(), nullable=True), sa.Column('cor_dod_id', sa.String(), nullable=True), sa.Column('so_first_name', sa.String(), nullable=True), sa.Column('so_last_name', sa.String(), nullable=True), sa.Column('so_email', sa.String(), nullable=True), sa.Column('so_dod_id', sa.String(), nullable=True), sa.Column('number', sa.String(), nullable=True), sa.Column('loa', sa.ARRAY(sa.String()), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), sa.ForeignKeyConstraint(['workspace_id'], ['workspaces.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('number') ) op.alter_column('workspaces', 'request_id', existing_type=postgresql.UUID(), nullable=True) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### conn = op.get_bind() conn.execute("DELETE FROM workspace_roles wr USING workspaces w WHERE w.id=wr.workspace_id AND w.request_id IS NULL") conn.execute("DELETE FROM audit_events ae USING workspaces w WHERE w.id=ae.workspace_id AND w.request_id IS NULL") conn.execute("DELETE FROM task_orders tasks USING workspaces w WHERE w.id=tasks.workspace_id AND w.request_id IS NULL") conn.execute("DELETE FROM workspaces WHERE request_id IS NULL") op.alter_column('workspaces', 'request_id', existing_type=postgresql.UUID(), nullable=False) op.drop_table('task_orders') # ### end Alembic commands ###