From a4e4c39797965fe40094681e485b97b18bfd522a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 9 Nov 2021 11:52:41 +0100 Subject: [PATCH] Fix: suppression semestres avec notifications absences --- app/models/absences.py | 2 +- ...added_cascade_on_absences_notifications.py | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/1efe07413835_added_cascade_on_absences_notifications.py diff --git a/app/models/absences.py b/app/models/absences.py index e6e243b7..658a390d 100644 --- a/app/models/absences.py +++ b/app/models/absences.py @@ -49,7 +49,7 @@ class AbsenceNotification(db.Model): nbabsjust = db.Column(db.Integer) formsemestre_id = db.Column( db.Integer, - db.ForeignKey("notes_formsemestre.id"), + db.ForeignKey("notes_formsemestre.id", ondelete="CASCADE"), ) diff --git a/migrations/versions/1efe07413835_added_cascade_on_absences_notifications.py b/migrations/versions/1efe07413835_added_cascade_on_absences_notifications.py new file mode 100644 index 00000000..c568000c --- /dev/null +++ b/migrations/versions/1efe07413835_added_cascade_on_absences_notifications.py @@ -0,0 +1,30 @@ +"""added cascade on absences_notifications + +Revision ID: 1efe07413835 +Revises: 75cf18659984 +Create Date: 2021-11-09 11:49:31.739803 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '1efe07413835' +down_revision = '75cf18659984' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint('absences_notifications_formsemestre_id_fkey', 'absences_notifications', type_='foreignkey') + op.create_foreign_key(None, 'absences_notifications', 'notes_formsemestre', ['formsemestre_id'], ['id'], ondelete='CASCADE') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'absences_notifications', type_='foreignkey') + op.create_foreign_key('absences_notifications_formsemestre_id_fkey', 'absences_notifications', 'notes_formsemestre', ['formsemestre_id'], ['id']) + # ### end Alembic commands ###