This commit is contained in:
Arthur ZHU 2022-04-18 18:02:32 +02:00
parent eb288fa6a1
commit 5ba99a1b9e
2 changed files with 19 additions and 32 deletions

View File

@ -35,13 +35,13 @@ class Entreprise(db.Model):
} }
class EntrepriseSite(db.Model): # class EntrepriseSite(db.Model):
__tablename__ = "are_sites" # __tablename__ = "are_sites"
id = db.Column(db.Integer, primary_key=True) # id = db.Column(db.Integer, primary_key=True)
entreprise_id = db.Column( # entreprise_id = db.Column(
db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") # db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade")
) # )
nom = db.Column(db.Text) # nom = db.Column(db.Text)
class EntrepriseCorrespondant(db.Model): class EntrepriseCorrespondant(db.Model):
@ -50,7 +50,7 @@ class EntrepriseCorrespondant(db.Model):
entreprise_id = db.Column( entreprise_id = db.Column(
db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") 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) nom = db.Column(db.Text)
prenom = db.Column(db.Text) prenom = db.Column(db.Text)
telephone = db.Column(db.Text) telephone = db.Column(db.Text)

View File

@ -1,8 +1,8 @@
"""tables module gestion relations entreprises """tables module gestion relations entreprises
Revision ID: 2a99f5553555 Revision ID: e5043b68e6b9
Revises: b9aadc10227f Revises: b9aadc10227f
Create Date: 2022-04-15 18:12:46.620653 Create Date: 2022-04-04 09:14:54.605480
""" """
from alembic import op from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
from sqlalchemy.dialects import postgresql from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = "2a99f5553555" revision = "e5043b68e6b9"
down_revision = "b9aadc10227f" down_revision = "b9aadc10227f"
branch_labels = None branch_labels = None
depends_on = None depends_on = None
@ -65,10 +65,15 @@ def upgrade():
sa.PrimaryKeyConstraint("id"), sa.PrimaryKeyConstraint("id"),
) )
op.create_table( op.create_table(
"are_sites", "are_correspondants",
sa.Column("id", sa.Integer(), nullable=False), sa.Column("id", sa.Integer(), nullable=False),
sa.Column("entreprise_id", sa.Integer(), nullable=True), sa.Column("entreprise_id", sa.Integer(), nullable=True),
sa.Column("nom", sa.Text(), 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( sa.ForeignKeyConstraint(
["entreprise_id"], ["are_entreprises.id"], ondelete="cascade" ["entreprise_id"], ["are_entreprises.id"], ondelete="cascade"
), ),
@ -90,23 +95,6 @@ def upgrade():
), ),
sa.PrimaryKeyConstraint("id"), 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( op.create_table(
"are_offres", "are_offres",
sa.Column("id", sa.Integer(), nullable=False), sa.Column("id", sa.Integer(), nullable=False),
@ -176,9 +164,9 @@ def upgrade():
sa.ForeignKeyConstraint(["offre_id"], ["are_offres.id"], ondelete="cascade"), sa.ForeignKeyConstraint(["offre_id"], ["are_offres.id"], ondelete="cascade"),
sa.PrimaryKeyConstraint("id"), sa.PrimaryKeyConstraint("id"),
) )
op.drop_index("ix_entreprises_dept_id", table_name="entreprises")
op.drop_table("entreprise_contact") op.drop_table("entreprise_contact")
op.drop_table("entreprise_correspondant") op.drop_table("entreprise_correspondant")
op.drop_index("ix_entreprises_dept_id", table_name="entreprises")
op.drop_table("entreprises") op.drop_table("entreprises")
# ### end Alembic commands ### # ### end Alembic commands ###
@ -276,9 +264,8 @@ def downgrade():
op.drop_table("are_envoi_offre_etudiant") op.drop_table("are_envoi_offre_etudiant")
op.drop_table("are_envoi_offre") op.drop_table("are_envoi_offre")
op.drop_table("are_offres") op.drop_table("are_offres")
op.drop_table("are_correspondants")
op.drop_table("are_stages_apprentissages") 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_contacts")
op.drop_table("are_preferences") op.drop_table("are_preferences")
op.drop_table("are_logs") op.drop_table("are_logs")