From 259b2a449d2371caeafc149dbbfa3be0f53d91d5 Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Fri, 6 May 2022 18:50:56 +0200 Subject: [PATCH] taxe apprentissage, changement historique, association --- ...a_ajout_taxe_apprentissage_association_.py | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 migrations/versions/2b872cb116ca_ajout_taxe_apprentissage_association_.py diff --git a/migrations/versions/2b872cb116ca_ajout_taxe_apprentissage_association_.py b/migrations/versions/2b872cb116ca_ajout_taxe_apprentissage_association_.py new file mode 100644 index 000000000..8cab659d9 --- /dev/null +++ b/migrations/versions/2b872cb116ca_ajout_taxe_apprentissage_association_.py @@ -0,0 +1,79 @@ +"""ajout taxe apprentissage, association, changement historique + +Revision ID: 2b872cb116ca +Revises: d5b3bdd1d622 +Create Date: 2022-05-06 18:16:58.727052 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "2b872cb116ca" +down_revision = "d5b3bdd1d622" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "are_taxe_apprentissage", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("entreprise_id", sa.Integer(), nullable=True), + sa.Column("annee", sa.Integer(), nullable=True), + sa.Column("montant", sa.Integer(), nullable=True), + sa.Column("notes", sa.Text(), nullable=True), + sa.ForeignKeyConstraint( + ["entreprise_id"], ["are_entreprises.id"], ondelete="cascade" + ), + sa.PrimaryKeyConstraint("id"), + ) + op.add_column( + "are_entreprises", sa.Column("association", sa.Boolean(), nullable=True) + ) + op.add_column("are_logs", sa.Column("entreprise_id", sa.Integer(), nullable=True)) + op.add_column("are_logs", sa.Column("object_id", sa.Integer(), nullable=True)) + op.alter_column( + "are_logs", + "object", + existing_type=sa.INTEGER(), + type_=sa.Text(), + existing_nullable=True, + ) + op.create_index( + op.f("ix_scolar_news_authenticated_user"), + "scolar_news", + ["authenticated_user"], + unique=False, + ) + op.create_index(op.f("ix_scolar_news_date"), "scolar_news", ["date"], unique=False) + op.create_index( + op.f("ix_scolar_news_object"), "scolar_news", ["object"], unique=False + ) + op.create_index(op.f("ix_scolar_news_type"), "scolar_news", ["type"], unique=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f("ix_scolar_news_type"), table_name="scolar_news") + op.drop_index(op.f("ix_scolar_news_object"), table_name="scolar_news") + op.drop_index(op.f("ix_scolar_news_date"), table_name="scolar_news") + op.drop_index(op.f("ix_scolar_news_authenticated_user"), table_name="scolar_news") + op.execute( + "alter table are_logs alter column object set data type int using object::integer" + ) + op.alter_column( + "are_logs", + "object", + existing_type=sa.Text(), + type_=sa.INTEGER(), + existing_nullable=True, + ) + op.drop_column("are_logs", "object_id") + op.drop_column("are_logs", "entreprise_id") + op.drop_column("are_entreprises", "association") + op.drop_table("are_taxe_apprentissage") + # ### end Alembic commands ###