"""Rename duns table to sam_recipient

Revision ID: 7896e714ba8e
Revises: 56dee789619d
Create Date: 2022-04-20 12:01:48.697436

"""

# revision identifiers, used by Alembic.
revision = '7896e714ba8e'
down_revision = '56dee789619d'
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.execute("ALTER TABLE duns RENAME TO sam_recipient")
    op.execute("ALTER TABLE sam_recipient RENAME COLUMN duns_id TO sam_recipient_id")
    op.execute("ALTER SEQUENCE duns_duns_id_seq RENAME TO sam_recipient_sam_recipient_id_seq")
    op.execute("ALTER INDEX duns_pkey RENAME TO sam_recipient_pkey")
    op.execute("ALTER INDEX ix_duns_awardee_or_recipient_uniqu RENAME TO ix_sam_recipient_awardee_or_recipient_uniqu")
    op.execute("ALTER INDEX ix_duns_activation_date RENAME TO ix_sam_recipient_activation_date")
    op.execute("ALTER INDEX ix_duns_deactivation_date RENAME TO ix_sam_recipient_deactivation_date")
    op.execute("ALTER INDEX ix_duns_expiration_date RENAME TO ix_sam_recipient_expiration_date")
    op.execute("ALTER INDEX ix_duns_registration_date RENAME TO ix_sam_recipient_registration_date")
    op.execute("ALTER INDEX ix_duns_uei RENAME TO ix_sam_recipient_uei")
    op.execute("ALTER INDEX ix_duns_uei_upper RENAME TO ix_sam_recipient_uei_upper")
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("ALTER INDEX ix_sam_recipient_uei_upper RENAME TO ix_duns_uei_upper")
    op.execute("ALTER INDEX ix_sam_recipient_uei RENAME TO ix_duns_uei")
    op.execute("ALTER INDEX ix_sam_recipient_registration_date RENAME TO ix_duns_registration_date")
    op.execute("ALTER INDEX ix_sam_recipient_expiration_date RENAME TO ix_duns_expiration_date")
    op.execute("ALTER INDEX ix_sam_recipient_deactivation_date RENAME TO ix_duns_deactivation_date")
    op.execute("ALTER INDEX ix_sam_recipient_activation_date RENAME TO ix_duns_activation_date")
    op.execute("ALTER INDEX ix_sam_recipient_awardee_or_recipient_uniqu RENAME TO ix_duns_awardee_or_recipient_uniqu")
    op.execute("ALTER INDEX sam_recipient_pkey RENAME TO duns_pkey")
    op.execute("ALTER SEQUENCE sam_recipient_sam_recipient_id_seq RENAME TO duns_duns_id_seq")
    op.execute("ALTER TABLE sam_recipient RENAME COLUMN sam_recipient_id TO duns_id")
    op.execute("ALTER TABLE sam_recipient RENAME TO duns")
    # ### end Alembic commands ###

