diff --git a/app/models/formations.py b/app/models/formations.py index 756879d593..063bd624d4 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 0000000000..8d888c6836 --- /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 ###