Find a SQL query for deleting forum thread subscriptions for people who left a district or working-group
Problem
Foodsavers who left a district/working-group are still getting email notifications (with content!) for forum threads. While the root problem seems to be solved in #593 (closed) there is some cleaning work to do. This query once being executed solves it for everyone wo had this problem till today.
This speed things up for support requests and makes it even more useful since we need it for cleaning in #682 (closed) up anyway.
Task description
The task is to build a SQL query, which deletes subscriptions out of fs_theme_follower
for every foodsaver who is not in the district/region/bezirk anymore where this thread/theme belongs to.
Possible solution
This can probably be done by joining and deleting whats left?:
fs_foodsaver_has_bezirk
<-> fs_bezirk_has_theme
<-> fs_theme_follower
Related tables
I beleive these three tables and collumns are needed:
fs_foodsaver_has_bezirk
foodsaver_id
bezirk_id
fs_bezirk_has_theme
bezirk_id
theme_id
fs_theme_follower
theme_id
foodsaver_id
Additional info
I try to be available for testing this query locally.