""" adding total_obligations table

Revision ID: 9e1acf1450dc
Revises: 8b8e9fe94b4a
Create Date: 2021-02-03 18:24:27.124242

"""

# revision identifiers, used by Alembic.
revision = '9e1acf1450dc'
down_revision = '8b8e9fe94b4a'
branch_labels = None
depends_on = None

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

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('total_obligations',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('total_obligations_id', sa.Integer(), nullable=False),
    sa.Column('submission_id', sa.Integer(), nullable=False),
    sa.Column('total_obligations', sa.Numeric(), nullable=True),
    sa.Column('total_proc_obligations', sa.Numeric(), nullable=True),
    sa.Column('total_asst_obligations', sa.Numeric(), nullable=True),
    sa.ForeignKeyConstraint(['submission_id'], ['submission.submission_id'], name='fk_total_obligations_submission_id', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('total_obligations_id')
    )
    op.create_index(op.f('ix_total_obligations_submission_id'), 'total_obligations', ['submission_id'], unique=True)
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_total_obligations_submission_id'), table_name='total_obligations')
    op.drop_table('total_obligations')
    # ### end Alembic commands ###

