"""Adding certified_total_obligations table

Revision ID: a9bfc7a2bd16
Revises: 9e1acf1450dc
Create Date: 2021-03-18 11:04:34.942653

"""

# revision identifiers, used by Alembic.
revision = 'a9bfc7a2bd16'
down_revision = '9e1acf1450dc'
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('certified_total_obligations',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('certified_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_certified_total_obligations_submission_id', ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('certified_total_obligations_id')
    )
    op.create_index(op.f('ix_certified_total_obligations_submission_id'), 'certified_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_certified_total_obligations_submission_id'), table_name='certified_total_obligations')
    op.drop_table('certified_total_obligations')
    # ### end Alembic commands ###

