"""suppression colonne are_correspondants, ajout siret provisoire, siret cle unique

Revision ID: cb360caa3dac
Revises: 0b337376e9f7
Create Date: 2022-07-13 15:52:14.113530

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'cb360caa3dac'
down_revision = '0b337376e9f7'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('are_correspondants_entreprise_id_fkey', 'are_correspondants', type_='foreignkey')
    op.drop_column('are_correspondants', 'entreprise_id')
    op.add_column('are_entreprises', sa.Column('siret_provisoire', sa.Boolean(), nullable=True))
    op.create_index(op.f('ix_are_entreprises_siret'), 'are_entreprises', ['siret'], unique=True)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_are_entreprises_siret'), table_name='are_entreprises')
    op.drop_column('are_entreprises', 'siret_provisoire')
    op.add_column('are_correspondants', sa.Column('entreprise_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('are_correspondants_entreprise_id_fkey', 'are_correspondants', 'are_entreprises', ['entreprise_id'], ['id'], ondelete='CASCADE')
    # ### end Alembic commands ###
