From 038157675063e380f4476074ea9a832f4974030c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 19 Sep 2021 21:31:35 +0200 Subject: [PATCH] modif contrainte sur formations --- app/models/formations.py | 2 +- ...13c9fbd_modif_contrainte_sur_formations.py | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/f86c013c9fbd_modif_contrainte_sur_formations.py diff --git a/app/models/formations.py b/app/models/formations.py index 756879d5..063bd624 100644 --- a/app/models/formations.py +++ b/app/models/formations.py @@ -11,7 +11,7 @@ class NotesFormation(db.Model): """Programme pédagogique d'une formation""" __tablename__ = "notes_formations" - __table_args__ = (db.UniqueConstraint("acronyme", "titre", "version"),) + __table_args__ = (db.UniqueConstraint("dept_id", "acronyme", "titre", "version"),) id = db.Column(db.Integer, primary_key=True) formation_id = db.synonym("id") diff --git a/migrations/versions/f86c013c9fbd_modif_contrainte_sur_formations.py b/migrations/versions/f86c013c9fbd_modif_contrainte_sur_formations.py new file mode 100644 index 00000000..8d888c68 --- /dev/null +++ b/migrations/versions/f86c013c9fbd_modif_contrainte_sur_formations.py @@ -0,0 +1,30 @@ +"""modif contrainte sur formations + +Revision ID: f86c013c9fbd +Revises: 669065fb2d20 +Create Date: 2021-09-19 21:30:42.240422 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'f86c013c9fbd' +down_revision = '669065fb2d20' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint('notes_formations_acronyme_titre_version_key', 'notes_formations', type_='unique') + op.create_unique_constraint(None, 'notes_formations', ['dept_id', 'acronyme', 'titre', 'version']) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'notes_formations', type_='unique') + op.create_unique_constraint('notes_formations_acronyme_titre_version_key', 'notes_formations', ['acronyme', 'titre', 'version']) + # ### end Alembic commands ###