From a06854eb1247a491d3730266f80d895b148a9150 Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Tue, 19 Apr 2022 17:40:17 +0200 Subject: [PATCH] correction migrations --- ...b81be_tables_module_gestion_relations_.py} | 31 +--- ...0f86c_tables_module_gestions_relations_.py | 158 ++++++++++++++++++ 2 files changed, 164 insertions(+), 25 deletions(-) rename migrations/versions/{e5043b68e6b9_tables_module_gestion_relations_.py => af05f03b81be_tables_module_gestion_relations_.py} (91%) create mode 100644 migrations/versions/e97b2a10f86c_tables_module_gestions_relations_.py diff --git a/migrations/versions/e5043b68e6b9_tables_module_gestion_relations_.py b/migrations/versions/af05f03b81be_tables_module_gestion_relations_.py similarity index 91% rename from migrations/versions/e5043b68e6b9_tables_module_gestion_relations_.py rename to migrations/versions/af05f03b81be_tables_module_gestion_relations_.py index bc57fbf5b..7f23ca9fc 100644 --- a/migrations/versions/e5043b68e6b9_tables_module_gestion_relations_.py +++ b/migrations/versions/af05f03b81be_tables_module_gestion_relations_.py @@ -1,8 +1,8 @@ """tables module gestion relations entreprises -Revision ID: e5043b68e6b9 +Revision ID: af05f03b81be Revises: b9aadc10227f -Create Date: 2022-04-04 09:14:54.605480 +Create Date: 2022-03-01 17:12:32.927643 """ from alembic import op @@ -10,7 +10,7 @@ import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = "e5043b68e6b9" +revision = "af05f03b81be" down_revision = "b9aadc10227f" branch_labels = None depends_on = None @@ -54,19 +54,6 @@ def upgrade(): op.create_table( "are_contacts", sa.Column("id", sa.Integer(), nullable=False), - sa.Column("date", sa.DateTime(timezone=True), nullable=True), - sa.Column("user", sa.Integer(), nullable=True), - sa.Column("entreprise", sa.Integer(), nullable=True), - sa.Column("notes", sa.Text(), nullable=True), - sa.ForeignKeyConstraint( - ["entreprise"], ["are_entreprises.id"], ondelete="cascade" - ), - sa.ForeignKeyConstraint(["user"], ["user.id"], ondelete="cascade"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_table( - "are_correspondants", - sa.Column("id", sa.Integer(), nullable=False), sa.Column("entreprise_id", sa.Integer(), nullable=True), sa.Column("nom", sa.Text(), nullable=True), sa.Column("prenom", sa.Text(), nullable=True), @@ -80,7 +67,7 @@ def upgrade(): sa.PrimaryKeyConstraint("id"), ) op.create_table( - "are_stages_apprentissages", + "are_etudiants", sa.Column("id", sa.Integer(), nullable=False), sa.Column("entreprise_id", sa.Integer(), nullable=True), sa.Column("etudid", sa.Integer(), nullable=True), @@ -89,7 +76,6 @@ def upgrade(): sa.Column("date_fin", sa.Date(), nullable=True), sa.Column("formation_text", sa.Text(), nullable=True), sa.Column("formation_scodoc", sa.Integer(), nullable=True), - sa.Column("notes", sa.Text(), nullable=True), sa.ForeignKeyConstraint( ["entreprise_id"], ["are_entreprises.id"], ondelete="cascade" ), @@ -112,10 +98,6 @@ def upgrade(): sa.Column("duree", sa.Text(), nullable=True), sa.Column("expiration_date", sa.Date(), nullable=True), sa.Column("expired", sa.Boolean(), nullable=True), - sa.Column("correspondant_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint( - ["correspondant_id"], ["are_correspondants.id"], ondelete="cascade" - ), sa.ForeignKeyConstraint( ["entreprise_id"], ["are_entreprises.id"], ondelete="cascade" ), @@ -164,9 +146,9 @@ def upgrade(): sa.ForeignKeyConstraint(["offre_id"], ["are_offres.id"], ondelete="cascade"), sa.PrimaryKeyConstraint("id"), ) - op.drop_index("ix_entreprises_dept_id", table_name="entreprises") op.drop_table("entreprise_contact") op.drop_table("entreprise_correspondant") + op.drop_index("ix_entreprises_dept_id", table_name="entreprises") op.drop_table("entreprises") # ### end Alembic commands ### @@ -264,8 +246,7 @@ def downgrade(): op.drop_table("are_envoi_offre_etudiant") op.drop_table("are_envoi_offre") op.drop_table("are_offres") - op.drop_table("are_stages_apprentissages") - op.drop_table("are_correspondants") + op.drop_table("are_etudiants") op.drop_table("are_contacts") op.drop_table("are_preferences") op.drop_table("are_logs") diff --git a/migrations/versions/e97b2a10f86c_tables_module_gestions_relations_.py b/migrations/versions/e97b2a10f86c_tables_module_gestions_relations_.py new file mode 100644 index 000000000..3580022f9 --- /dev/null +++ b/migrations/versions/e97b2a10f86c_tables_module_gestions_relations_.py @@ -0,0 +1,158 @@ +"""tables module gestions relations entreprises suite + +Revision ID: e97b2a10f86c +Revises: af05f03b81be +Create Date: 2022-04-19 17:39:08.197835 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "e97b2a10f86c" +down_revision = "af05f03b81be" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "are_correspondants", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("entreprise_id", sa.Integer(), nullable=True), + sa.Column("nom", sa.Text(), nullable=True), + sa.Column("prenom", sa.Text(), nullable=True), + sa.Column("telephone", sa.Text(), nullable=True), + sa.Column("mail", sa.Text(), nullable=True), + sa.Column("poste", sa.Text(), nullable=True), + sa.Column("service", sa.Text(), nullable=True), + sa.ForeignKeyConstraint( + ["entreprise_id"], ["are_entreprises.id"], ondelete="cascade" + ), + sa.PrimaryKeyConstraint("id"), + ) + op.create_table( + "are_stages_apprentissages", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("entreprise_id", sa.Integer(), nullable=True), + sa.Column("etudid", sa.Integer(), nullable=True), + sa.Column("type_offre", sa.Text(), nullable=True), + sa.Column("date_debut", sa.Date(), nullable=True), + sa.Column("date_fin", sa.Date(), nullable=True), + sa.Column("formation_text", sa.Text(), nullable=True), + sa.Column("formation_scodoc", sa.Integer(), nullable=True), + sa.Column("notes", sa.Text(), nullable=True), + sa.ForeignKeyConstraint( + ["entreprise_id"], ["are_entreprises.id"], ondelete="cascade" + ), + sa.PrimaryKeyConstraint("id"), + ) + op.drop_table("are_etudiants") + op.add_column( + "are_contacts", sa.Column("date", sa.DateTime(timezone=True), nullable=True) + ) + op.add_column("are_contacts", sa.Column("user", sa.Integer(), nullable=True)) + op.add_column("are_contacts", sa.Column("entreprise", sa.Integer(), nullable=True)) + op.add_column("are_contacts", sa.Column("notes", sa.Text(), nullable=True)) + op.drop_constraint( + "are_contacts_entreprise_id_fkey", "are_contacts", type_="foreignkey" + ) + op.create_foreign_key( + None, + "are_contacts", + "are_entreprises", + ["entreprise"], + ["id"], + ondelete="cascade", + ) + op.create_foreign_key( + None, "are_contacts", "user", ["user"], ["id"], ondelete="cascade" + ) + op.drop_column("are_contacts", "nom") + op.drop_column("are_contacts", "telephone") + op.drop_column("are_contacts", "service") + op.drop_column("are_contacts", "entreprise_id") + op.drop_column("are_contacts", "mail") + op.drop_column("are_contacts", "poste") + op.drop_column("are_contacts", "prenom") + op.add_column( + "are_offres", sa.Column("correspondant_id", sa.Integer(), nullable=True) + ) + op.create_foreign_key( + None, + "are_offres", + "are_correspondants", + ["correspondant_id"], + ["id"], + ondelete="cascade", + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, "are_offres", type_="foreignkey") + op.drop_column("are_offres", "correspondant_id") + op.add_column( + "are_contacts", + sa.Column("prenom", sa.TEXT(), autoincrement=False, nullable=True), + ) + op.add_column( + "are_contacts", + sa.Column("poste", sa.TEXT(), autoincrement=False, nullable=True), + ) + op.add_column( + "are_contacts", sa.Column("mail", sa.TEXT(), autoincrement=False, nullable=True) + ) + op.add_column( + "are_contacts", + sa.Column("entreprise_id", sa.INTEGER(), autoincrement=False, nullable=True), + ) + op.add_column( + "are_contacts", + sa.Column("service", sa.TEXT(), autoincrement=False, nullable=True), + ) + op.add_column( + "are_contacts", + sa.Column("telephone", sa.TEXT(), autoincrement=False, nullable=True), + ) + op.add_column( + "are_contacts", sa.Column("nom", sa.TEXT(), autoincrement=False, nullable=True) + ) + op.drop_constraint(None, "are_contacts", type_="foreignkey") + op.drop_constraint(None, "are_contacts", type_="foreignkey") + op.create_foreign_key( + "are_contacts_entreprise_id_fkey", + "are_contacts", + "are_entreprises", + ["entreprise_id"], + ["id"], + ondelete="CASCADE", + ) + op.drop_column("are_contacts", "notes") + op.drop_column("are_contacts", "entreprise") + op.drop_column("are_contacts", "user") + op.drop_column("are_contacts", "date") + op.create_table( + "are_etudiants", + sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("entreprise_id", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("etudid", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("type_offre", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("date_debut", sa.DATE(), autoincrement=False, nullable=True), + sa.Column("date_fin", sa.DATE(), autoincrement=False, nullable=True), + sa.Column("formation_text", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("formation_scodoc", sa.INTEGER(), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint( + ["entreprise_id"], + ["are_entreprises.id"], + name="are_etudiants_entreprise_id_fkey", + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint("id", name="are_etudiants_pkey"), + ) + op.drop_table("are_stages_apprentissages") + op.drop_table("are_correspondants") + # ### end Alembic commands ###