1
0
Fork 0
ScoDoc-Front/migrations/versions/00ad500fb118_but_refcomp.py

208 lines
7.1 KiB
Python

"""but_refcomp
Revision ID: 00ad500fb118
Revises: a26b3103697d
Create Date: 2021-12-02 09:01:03.167131
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "00ad500fb118"
down_revision = "a26b3103697d"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"apc_referentiel_competences",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("dept_id", sa.Integer(), nullable=True),
sa.Column("specialite", sa.Text(), nullable=True),
sa.Column("specialite_long", sa.Text(), nullable=True),
sa.Column("type_titre", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(
["dept_id"],
["departement.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_apc_referentiel_competences_dept_id"),
"apc_referentiel_competences",
["dept_id"],
unique=False,
)
op.create_table(
"apc_competence",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("referentiel_id", sa.Integer(), nullable=False),
sa.Column("titre", sa.Text(), nullable=False),
sa.Column("titre_long", sa.Text(), nullable=True),
sa.Column("numero", sa.Integer(), nullable=True),
sa.Column("couleur", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(
["referentiel_id"],
["apc_referentiel_competences.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"apc_parcours",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("referentiel_id", sa.Integer(), nullable=False),
sa.Column("numero", sa.Integer(), nullable=True),
sa.Column("code", sa.Text(), nullable=False),
sa.Column("libelle", sa.Text(), nullable=False),
sa.ForeignKeyConstraint(
["referentiel_id"],
["apc_referentiel_competences.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"apc_annee_parcours",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("parcours_id", sa.Integer(), nullable=False),
sa.Column("numero", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(
["parcours_id"],
["apc_parcours.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"apc_composante_essentielle",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("competence_id", sa.Integer(), nullable=False),
sa.Column("libelle", sa.Text(), nullable=False),
sa.ForeignKeyConstraint(
["competence_id"],
["apc_competence.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"apc_niveau",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("competence_id", sa.Integer(), nullable=False),
sa.Column("libelle", sa.Text(), nullable=False),
sa.Column("annee", sa.Text(), nullable=False),
sa.Column("ordre", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["competence_id"],
["apc_competence.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"apc_situation_pro",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("competence_id", sa.Integer(), nullable=False),
sa.Column("libelle", sa.Text(), nullable=False),
sa.ForeignKeyConstraint(
["competence_id"],
["apc_competence.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"apc_app_critique",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("niveau_id", sa.Integer(), nullable=False),
sa.Column("code", sa.Text(), nullable=False),
sa.Column("libelle", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(
["niveau_id"],
["apc_niveau.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"apc_parcours_niveau_competence",
sa.Column("competence_id", sa.Integer(), nullable=False),
sa.Column("annee_parcours_id", sa.Integer(), nullable=False),
sa.Column("niveau", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["annee_parcours_id"], ["apc_annee_parcours.id"], ondelete="CASCADE"
),
sa.ForeignKeyConstraint(
["competence_id"], ["apc_competence.id"], ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("competence_id", "annee_parcours_id"),
)
op.create_table(
"apc_modules_acs",
sa.Column("module_id", sa.Integer(), nullable=True),
sa.Column("app_crit_id", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(
["app_crit_id"],
["apc_app_critique.id"],
),
sa.ForeignKeyConstraint(
["module_id"],
["notes_modules.id"],
),
)
# op.drop_table("app_crit")
# op.drop_table("modules_acs")
op.add_column(
"notes_formations",
sa.Column("referentiel_competence_id", sa.Integer(), nullable=True),
)
op.create_foreign_key(
"notes_formations_referentiel_competence_id_fkey",
"notes_formations",
"apc_referentiel_competences",
["referentiel_competence_id"],
["id"],
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"notes_formations_referentiel_competence_id_fkey",
"notes_formations",
type_="foreignkey",
)
op.drop_column("notes_formations", "referentiel_competence_id")
# op.create_table(
# "modules_acs",
# sa.Column("module_id", sa.INTEGER(), autoincrement=False, nullable=True),
# sa.Column("ac_id", sa.INTEGER(), autoincrement=False, nullable=True),
# sa.ForeignKeyConstraint(
# ["ac_id"], ["app_crit.id"], name="modules_acs_ac_id_fkey"
# ),
# sa.ForeignKeyConstraint(
# ["module_id"], ["notes_modules.id"], name="modules_acs_module_id_fkey"
# ),
# )
# op.create_table(
# "app_crit",
# sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
# sa.Column("code", sa.TEXT(), autoincrement=False, nullable=False),
# sa.Column("titre", sa.TEXT(), autoincrement=False, nullable=True),
# sa.PrimaryKeyConstraint("id", name="app_crit_pkey"),
# )
op.drop_table("apc_modules_acs")
op.drop_table("apc_parcours_niveau_competence")
op.drop_table("apc_app_critique")
op.drop_table("apc_situation_pro")
op.drop_table("apc_niveau")
op.drop_table("apc_composante_essentielle")
op.drop_table("apc_annee_parcours")
op.drop_table("apc_parcours")
op.drop_table("apc_competence")
op.drop_index(
op.f("ix_apc_referentiel_competences_dept_id"),
table_name="apc_referentiel_competences",
)
op.drop_table("apc_referentiel_competences")
# ### end Alembic commands ###