Add a where clause to join to NotificationHistory, this is some extra assurance that the Notification will not be deleted unless the history exists.

This commit is contained in:
Rebecca Law
2019-06-03 11:47:02 +01:00
parent c23ae15f32
commit b8399b8b9b
2 changed files with 19 additions and 1 deletions

View File

@@ -344,7 +344,8 @@ def _delete_notifications(
).filter(
Notification.notification_type == notification_type,
Notification.service_id == service_id,
Notification.created_at < date_to_delete_from
Notification.created_at < date_to_delete_from,
NotificationHistory.id == Notification.id
).limit(query_limit).subquery()
number_deleted = db.session.query(Notification).filter(