From a78dcad96ccfcebe50e432dccc74730edc04357a Mon Sep 17 00:00:00 2001 From: Alec Smecher Date: Fri, 2 Mar 2018 13:08:43 -0800 Subject: [PATCH] pkp/pkp-lib#3412 Clean up notifications on announcement deletion --- dbscripts/xml/upgrade/3.1.1_update.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbscripts/xml/upgrade/3.1.1_update.xml b/dbscripts/xml/upgrade/3.1.1_update.xml index 091eef98ed3..368ab2b3448 100644 --- a/dbscripts/xml/upgrade/3.1.1_update.xml +++ b/dbscripts/xml/upgrade/3.1.1_update.xml @@ -53,4 +53,9 @@ UPDATE users SET citations = us. groupedGossips FROM (SELECT user_id, string_agg(DISTINCT setting_value, ' ') AS groupedGossips FROM user_settings WHERE setting_name = 'gossip' AND setting_value <> '' GROUP BY user_id) AS us WHERE us.user_id = users.user_id DELETE FROM user_settings WHERE setting_name="gossip" + + DELETE n FROM notifications n LEFT JOIN announcements a ON (n.assoc_id = a.announcement_id) WHERE a.announcement_id IS NULL AND n.assoc_type = 522 + DELETE n FROM notifications n LEFT JOIN announcements a ON (n.assoc_id = a.announcement_id) WHERE a.announcement_id IS NULL AND n.assoc_type = 522 + DELETE FROM notifications USING notifications n LEFT JOIN announcements a ON (n.assoc_id = a.announcement_id) WHERE a.announcement_id IS NULL AND n.assoc_type = 522 AND notifications.notification_id = n.notification_id +