From 5ba99a1b9e0a5e9757515be81a1ab25f3df704e3 Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Mon, 18 Apr 2022 18:02:32 +0200 Subject: [PATCH] models --- app/entreprises/models.py | 16 ++++----- ...8e6b9_tables_module_gestion_relations_.py} | 35 ++++++------------- 2 files changed, 19 insertions(+), 32 deletions(-) rename migrations/versions/{2a99f5553555_tables_module_gestion_relations_.py => e5043b68e6b9_tables_module_gestion_relations_.py} (94%) diff --git a/app/entreprises/models.py b/app/entreprises/models.py index 949a05e7..90fcf335 100644 --- a/app/entreprises/models.py +++ b/app/entreprises/models.py @@ -35,13 +35,13 @@ class Entreprise(db.Model): } -class EntrepriseSite(db.Model): - __tablename__ = "are_sites" - id = db.Column(db.Integer, primary_key=True) - entreprise_id = db.Column( - db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") - ) - nom = db.Column(db.Text) +# class EntrepriseSite(db.Model): +# __tablename__ = "are_sites" +# id = db.Column(db.Integer, primary_key=True) +# entreprise_id = db.Column( +# db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") +# ) +# nom = db.Column(db.Text) class EntrepriseCorrespondant(db.Model): @@ -50,7 +50,7 @@ class EntrepriseCorrespondant(db.Model): entreprise_id = db.Column( db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") ) - site_id = db.Column(db.Integer, db.ForeignKey("are_sites.id", ondelete="cascade")) + # site_id = db.Column(db.Integer, db.ForeignKey("are_sites.id", ondelete="cascade")) nom = db.Column(db.Text) prenom = db.Column(db.Text) telephone = db.Column(db.Text) diff --git a/migrations/versions/2a99f5553555_tables_module_gestion_relations_.py b/migrations/versions/e5043b68e6b9_tables_module_gestion_relations_.py similarity index 94% rename from migrations/versions/2a99f5553555_tables_module_gestion_relations_.py rename to migrations/versions/e5043b68e6b9_tables_module_gestion_relations_.py index 6a5ca0c7..bc57fbf5 100644 --- a/migrations/versions/2a99f5553555_tables_module_gestion_relations_.py +++ b/migrations/versions/e5043b68e6b9_tables_module_gestion_relations_.py @@ -1,8 +1,8 @@ """tables module gestion relations entreprises -Revision ID: 2a99f5553555 +Revision ID: e5043b68e6b9 Revises: b9aadc10227f -Create Date: 2022-04-15 18:12:46.620653 +Create Date: 2022-04-04 09:14:54.605480 """ from alembic import op @@ -10,7 +10,7 @@ import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = "2a99f5553555" +revision = "e5043b68e6b9" down_revision = "b9aadc10227f" branch_labels = None depends_on = None @@ -65,10 +65,15 @@ def upgrade(): sa.PrimaryKeyConstraint("id"), ) op.create_table( - "are_sites", + "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" ), @@ -90,23 +95,6 @@ def upgrade(): ), 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("site_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.ForeignKeyConstraint(["site_id"], ["are_sites.id"], ondelete="cascade"), - sa.PrimaryKeyConstraint("id"), - ) op.create_table( "are_offres", sa.Column("id", sa.Integer(), nullable=False), @@ -176,9 +164,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 ### @@ -276,9 +264,8 @@ def downgrade(): op.drop_table("are_envoi_offre_etudiant") op.drop_table("are_envoi_offre") op.drop_table("are_offres") - op.drop_table("are_correspondants") op.drop_table("are_stages_apprentissages") - op.drop_table("are_sites") + op.drop_table("are_correspondants") op.drop_table("are_contacts") op.drop_table("are_preferences") op.drop_table("are_logs")