"""Adding UEI values to DUNS tables

Revision ID: e72f2699bcaa
Revises: 24e0fa72827a
Create Date: 2021-02-26 20:40:28.254073

"""

# revision identifiers, used by Alembic.
revision = 'e72f2699bcaa'
down_revision = '24e0fa72827a'
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.add_column('duns', sa.Column('uei', sa.Text(), nullable=True))
    op.add_column('duns', sa.Column('ultimate_parent_uei', sa.Text(), nullable=True))
    op.add_column('historic_duns', sa.Column('uei', sa.Text(), nullable=True))
    op.add_column('historic_duns', sa.Column('ultimate_parent_uei', sa.Text(), nullable=True))
    op.add_column('historic_duns', sa.Column('entity_structure', sa.Text(), nullable=True))
    op.create_index(op.f('ix_duns_uei'), 'duns', ['uei'], unique=False)
    op.create_index(op.f('ix_historic_duns_uei'), 'historic_duns', ['uei'], unique=False)
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_historic_duns_uei'), table_name='historic_duns')
    op.drop_column('historic_duns', 'entity_structure')
    op.drop_column('historic_duns', 'ultimate_parent_uei')
    op.drop_column('historic_duns', 'uei')
    op.drop_index(op.f('ix_duns_uei'), table_name='duns')
    op.drop_column('duns', 'ultimate_parent_uei')
    op.drop_column('duns', 'uei')
    # ### end Alembic commands ###

