"""fix fields

Revision ID: 0d83f32dd4f6
Revises: 13e280e193f8
Create Date: 2021-10-07 16:04:48.387283

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

# revision identifiers, used by Alembic.
revision = '0d83f32dd4f6'
down_revision = '13e280e193f8'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_invoice_items', sa.Column('invoice_id', sa.String(length=64), nullable=True))
    op.drop_index('ix_cmf_invoice_items_deal_id', table_name='cmf_invoice_items')
    op.create_index(op.f('ix_cmf_invoice_items_invoice_id'), 'cmf_invoice_items', ['invoice_id'], unique=False)
    op.drop_constraint('cmf_invoice_items_deal_id_fkey', 'cmf_invoice_items', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_invoice_items', 'cmf_invoice', ['invoice_id'], ['id'])
    op.drop_column('cmf_invoice_items', 'deal_id')
    op.create_index(op.f('ix_cmf_patch_name'), 'cmf_patch', ['name'], unique=False)
    op.drop_index('ix_cmf_person_home_project_id', table_name='cmf_person')
    op.drop_column('cmf_person', 'home_project_id')
    op.drop_column('cmf_person', 'is_internal')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_person', sa.Column('is_internal', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('cmf_person', sa.Column('home_project_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.create_index('ix_cmf_person_home_project_id', 'cmf_person', ['home_project_id'], unique=False)
    op.drop_index(op.f('ix_cmf_patch_name'), table_name='cmf_patch')
    op.add_column('cmf_invoice_items', sa.Column('deal_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cmf_invoice_items', type_='foreignkey')
    op.create_foreign_key('cmf_invoice_items_deal_id_fkey', 'cmf_invoice_items', 'cmf_deal', ['deal_id'], ['id'])
    op.drop_index(op.f('ix_cmf_invoice_items_invoice_id'), table_name='cmf_invoice_items')
    op.create_index('ix_cmf_invoice_items_deal_id', 'cmf_invoice_items', ['deal_id'], unique=False)
    op.drop_column('cmf_invoice_items', 'invoice_id')
    # ### end Alembic commands ###
