SELECT count(*)
FROM notifications
LEFT OUTER JOIN mentions
ON mentions.id = notifications.target_id
WHERE
notifications.target_type = 'Notifications::MentionedInComment'
AND mentions.id IS NULL;
To check if this only affects one mention, or multiple?
SELECT count(*)
FROM notifications
LEFT OUTER JOIN mentions
ON mentions.id = notifications.target_id
WHERE
notifications.type = 'Notifications::MentionedInComment'
AND mentions.id IS NULL;
Hm, odd. But at least it’s only one. You can get the ID of the broken notification with
SELECT notifications.id
FROM notifications
LEFT OUTER JOIN mentions
ON mentions.id = notifications.target_id
WHERE
notifications.type = 'Notifications::MentionedInComment'
AND mentions.id IS NULL;
Then, enter the diaspora folder, start a rails console with RAILS_ENV=production bin/rails c, and run
Notification.find(12345).destroy!
That will remove the broken notification, and the user should be able to look at their notifications again. Hard to say what went wrong that the system ended up in that state in the first place, but oh well.