DocScoDoc/migrations/versions/e5043b68e6b9_tables_module_gestion_relations_.py

274 lines
12 KiB
Python
Raw Normal View History

2022-02-04 17:12:56 +01:00
"""tables module gestion relations entreprises
2022-04-05 02:26:43 +02:00
Revision ID: e5043b68e6b9
2022-02-22 21:52:32 +01:00
Revises: b9aadc10227f
2022-04-05 02:26:43 +02:00
Create Date: 2022-04-04 09:14:54.605480
2022-02-04 17:12:56 +01:00
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
2022-04-05 02:26:43 +02:00
revision = "e5043b68e6b9"
2022-02-22 21:52:32 +01:00
down_revision = "b9aadc10227f"
2022-02-04 17:12:56 +01:00
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
2022-03-01 18:45:04 +01:00
"are_entreprises",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("siret", sa.Text(), nullable=True),
sa.Column("nom", sa.Text(), nullable=True),
sa.Column("adresse", sa.Text(), nullable=True),
sa.Column("codepostal", sa.Text(), nullable=True),
sa.Column("ville", sa.Text(), nullable=True),
sa.Column("pays", sa.Text(), nullable=True),
sa.Column("visible", sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"are_logs",
2022-02-04 17:12:56 +01:00
sa.Column("id", sa.Integer(), nullable=False),
sa.Column(
"date",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
sa.Column("authenticated_user", sa.Text(), nullable=True),
sa.Column("object", sa.Integer(), nullable=True),
sa.Column("text", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
2022-02-22 21:52:32 +01:00
op.create_table(
"are_preferences",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("name", sa.Text(), nullable=True),
sa.Column("value", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
2022-04-05 02:26:43 +02:00
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"),
)
2022-02-04 17:12:56 +01:00
op.create_table(
"are_correspondants",
2022-02-04 17:12:56 +01:00
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",
2022-02-04 17:12:56 +01:00
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),
2022-02-04 17:12:56 +01:00
sa.ForeignKeyConstraint(
["entreprise_id"], ["are_entreprises.id"], ondelete="cascade"
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
2022-03-01 18:45:04 +01:00
"are_offres",
2022-02-04 17:12:56 +01:00
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("entreprise_id", sa.Integer(), nullable=True),
sa.Column(
"date_ajout",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
sa.Column("intitule", sa.Text(), nullable=True),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("type_offre", sa.Text(), nullable=True),
sa.Column("missions", sa.Text(), nullable=True),
sa.Column("duree", sa.Text(), nullable=True),
sa.Column("expiration_date", sa.Date(), nullable=True),
2022-03-01 18:45:04 +01:00
sa.Column("expired", sa.Boolean(), nullable=True),
sa.Column("correspondant_id", sa.Integer(), nullable=True),
2022-03-04 17:10:07 +01:00
sa.ForeignKeyConstraint(
["correspondant_id"], ["are_correspondants.id"], ondelete="cascade"
2022-03-04 17:10:07 +01:00
),
2022-02-04 17:12:56 +01:00
sa.ForeignKeyConstraint(
["entreprise_id"], ["are_entreprises.id"], ondelete="cascade"
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
2022-03-01 18:45:04 +01:00
"are_envoi_offre",
2022-02-04 17:12:56 +01:00
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("sender_id", sa.Integer(), nullable=True),
sa.Column("receiver_id", sa.Integer(), nullable=True),
sa.Column("offre_id", sa.Integer(), nullable=True),
sa.Column(
"date_envoi",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
2022-03-01 18:45:04 +01:00
sa.ForeignKeyConstraint(["offre_id"], ["are_offres.id"], ondelete="cascade"),
2022-02-04 17:12:56 +01:00
sa.ForeignKeyConstraint(["receiver_id"], ["user.id"], ondelete="cascade"),
sa.ForeignKeyConstraint(["sender_id"], ["user.id"], ondelete="cascade"),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
2022-03-01 18:45:04 +01:00
"are_envoi_offre_etudiant",
2022-02-04 17:12:56 +01:00
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("sender_id", sa.Integer(), nullable=True),
sa.Column("receiver_id", sa.Integer(), nullable=True),
sa.Column("offre_id", sa.Integer(), nullable=True),
sa.Column(
"date_envoi",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
2022-03-01 18:45:04 +01:00
sa.ForeignKeyConstraint(["offre_id"], ["are_offres.id"], ondelete="cascade"),
2022-02-04 17:12:56 +01:00
sa.ForeignKeyConstraint(["receiver_id"], ["identite.id"], ondelete="cascade"),
sa.ForeignKeyConstraint(["sender_id"], ["user.id"], ondelete="cascade"),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
2022-03-01 18:45:04 +01:00
"are_offre_departement",
2022-02-04 17:12:56 +01:00
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("offre_id", sa.Integer(), nullable=True),
sa.Column("dept_id", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(["dept_id"], ["departement.id"], ondelete="cascade"),
2022-03-01 18:45:04 +01:00
sa.ForeignKeyConstraint(["offre_id"], ["are_offres.id"], ondelete="cascade"),
2022-02-04 17:12:56 +01:00
sa.PrimaryKeyConstraint("id"),
)
2022-04-05 02:26:43 +02:00
op.drop_index("ix_entreprises_dept_id", table_name="entreprises")
2022-02-04 17:12:56 +01:00
op.drop_table("entreprise_contact")
op.drop_table("entreprise_correspondant")
op.drop_table("entreprises")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"entreprises",
2022-02-22 21:52:32 +01:00
sa.Column(
"id",
sa.INTEGER(),
server_default=sa.text("nextval('entreprises_id_seq'::regclass)"),
autoincrement=True,
nullable=False,
),
2022-02-04 17:12:56 +01:00
sa.Column("nom", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("adresse", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("ville", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("codepostal", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("pays", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("localisation", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("dept_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column(
"date_creation",
postgresql.TIMESTAMP(timezone=True),
server_default=sa.text("now()"),
autoincrement=False,
nullable=True,
),
sa.Column("secteur", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("privee", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("plus10salaries", sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column("contact_origine", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("note", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("qualite_relation", sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(
["dept_id"], ["departement.id"], name="entreprises_dept_id_fkey"
),
sa.PrimaryKeyConstraint("id", name="entreprises_pkey"),
2022-02-22 21:52:32 +01:00
postgresql_ignore_search_path=False,
2022-02-04 17:12:56 +01:00
)
op.create_index("ix_entreprises_dept_id", "entreprises", ["dept_id"], unique=False)
op.create_table(
"entreprise_correspondant",
2022-04-05 02:26:43 +02:00
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column("entreprise_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("nom", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("prenom", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("civilite", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("fonction", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("phone1", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("phone2", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("mobile", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("mail1", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("mail2", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("fax", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("note", sa.TEXT(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(
["entreprise_id"],
["entreprises.id"],
name="entreprise_correspondant_entreprise_id_fkey",
),
sa.PrimaryKeyConstraint("id", name="entreprise_correspondant_pkey"),
)
2022-02-04 17:12:56 +01:00
op.create_table(
"entreprise_contact",
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column("entreprise_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column(
"entreprise_corresp_id", sa.INTEGER(), autoincrement=False, nullable=True
),
sa.Column("etudid", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("type_contact", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column(
"date",
postgresql.TIMESTAMP(timezone=True),
autoincrement=False,
nullable=True,
),
sa.Column("enseignant", sa.TEXT(), autoincrement=False, nullable=True),
sa.Column("description", sa.TEXT(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(
["entreprise_corresp_id"],
["entreprise_correspondant.id"],
name="entreprise_contact_entreprise_corresp_id_fkey",
),
sa.ForeignKeyConstraint(
["entreprise_id"],
["entreprises.id"],
name="entreprise_contact_entreprise_id_fkey",
),
sa.PrimaryKeyConstraint("id", name="entreprise_contact_pkey"),
)
2022-03-01 18:45:04 +01:00
op.drop_table("are_offre_departement")
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")
2022-04-05 02:26:43 +02:00
op.drop_table("are_contacts")
2022-02-22 21:52:32 +01:00
op.drop_table("are_preferences")
2022-03-01 18:45:04 +01:00
op.drop_table("are_logs")
2022-02-04 17:12:56 +01:00
op.drop_table("are_entreprises")
# ### end Alembic commands ###