Forum .LRN Q&A: Response to Forums and Notifications deleting threads problem in postgresql

The challenge seems to be that there is no mechanism to notify the notifications package that a forum thread was deleted. In other words, (I'm pretty sure that...) notification::request::delete is never called because nobody is calling it. Doing so would entail either modifying the forums package to be notifications-aware or implementing an observer.

A simpler solution might be to change on delete cascade to on delete set null and make sure the code never sends out notifications that have a null entry for object_id or request_id. In addition, the sweeper would have to be modified to delete any notifications that have null values in one or both of these columns.

I think it's acceptable, if not preferable, to have partially-fulfilled requests for deleted threads.