"""Create zips_historical table

Revision ID: eefb24761306
Revises: 7a7da8badfff
Create Date: 2022-11-14 11:52:32.985271

"""

# revision identifiers, used by Alembic.
revision = 'eefb24761306'
down_revision = '7a7da8badfff'
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('zips_historical',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('zips_historical_id', sa.Integer(), nullable=False),
        sa.Column('zip5', sa.Text(), nullable=True),
        sa.Column('zip_last4', sa.Text(), nullable=True),
        sa.Column('state_abbreviation', sa.Text(), nullable=True),
        sa.Column('county_number', sa.Text(), nullable=True),
        sa.Column('congressional_district_no', sa.Text(), nullable=True),
        sa.PrimaryKeyConstraint('zips_historical_id')
    )
    op.create_index(op.f('ix_zips_historical_congressional_district_no'), 'zips_historical', ['congressional_district_no'], unique=False)
    op.create_index(op.f('ix_zips_historical_county_number'), 'zips_historical', ['county_number'], unique=False)
    op.create_index(op.f('ix_zips_historical_state_abbreviation'), 'zips_historical', ['state_abbreviation'], unique=False)
    op.create_index(op.f('ix_zips_historical_zip5'), 'zips_historical', ['zip5'], unique=False)
    op.create_index('ix_zips_historical_zip5_state_abbreviation_county_number', 'zips_historical', ['zip5', 'state_abbreviation', 'county_number'], unique=False)
    op.create_index(op.f('ix_zips_historical_zip_last4'), 'zips_historical', ['zip_last4'], unique=False)
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_zips_historical_zip_last4'), table_name='zips_historical')
    op.drop_index('ix_zips_historical_zip5_state_abbreviation_county_number', table_name='zips_historical')
    op.drop_index(op.f('ix_zips_historical_zip5'), table_name='zips_historical')
    op.drop_index(op.f('ix_zips_historical_state_abbreviation'), table_name='zips_historical')
    op.drop_index(op.f('ix_zips_historical_county_number'), table_name='zips_historical')
    op.drop_index(op.f('ix_zips_historical_congressional_district_no'), table_name='zips_historical')
    op.drop_table('zips_historical')
    # ### end Alembic commands ###

