diff --git a/app/models/absences.py b/app/models/absences.py index e6e243b7c0..658a390de4 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 0000000000..c568000c10 --- /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 ###