"""emolument-facture repartition

Revision ID: 826c2810ab30
Revises: 13fcb71e77c1
Create Date: 2021-09-13 11:51:59.441107

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

# revision identifiers, used by Alembic.
revision = '826c2810ab30'
down_revision = '13fcb71e77c1'
branch_labels = None
depends_on = None

def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('emolument_affaire_repartition',
    sa.Column('emolument_affaire_id', sa.BigInteger(), nullable=False),
    sa.Column('facture_id', sa.BigInteger(), nullable=False),
    sa.Column('repartition', sa.Float(), nullable=False),
    sa.ForeignKeyConstraint(['emolument_affaire_id'], ['infolica.emolument_affaire.id'], name=op.f('fk_emolument_affaire_repartition_emolument_affaire_id_emolument_affaire')),
    sa.ForeignKeyConstraint(['facture_id'], ['infolica.facture.id'], name=op.f('fk_emolument_affaire_repartition_facture_id_facture')),
    sa.PrimaryKeyConstraint('emolument_affaire_id', 'facture_id', name=op.f('pk_emolument_affaire_repartition')),
    schema='infolica'
    )
    op.drop_table('emolument_facture')
    # ### end Alembic commands ###

def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('emolument_facture',
    sa.Column('id', sa.BIGINT(), autoincrement=True, nullable=False),
    sa.Column('facture_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('emolument_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('nombre', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('facteur_correctif', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False),
    sa.Column('batiment', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('montant', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['emolument_id'], ['tableau_emoluments.id'], name='fk_emolument_facture_emolument_id_tableau_emoluments'),
    sa.ForeignKeyConstraint(['facture_id'], ['facture.id'], name='fk_emolument_facture_facture_id_facture'),
    sa.PrimaryKeyConstraint('id', name='pk_emolument_facture')
    )
    op.drop_table('emolument_affaire_repartition', schema='infolica')
    # ### end Alembic commands ###
