Skip to content

Commit

Permalink
Make post delete script also delete context
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjrw committed Mar 9, 2024
1 parent bf54d56 commit 8404045
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion notifier/database/queries/delete_non_notifiable_posts.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
START TRANSACTION;

-- Purge posts that are no longer considered notifiable

DELETE
Expand Down Expand Up @@ -69,4 +71,26 @@ WHERE
OR thread_sub.sub = 1
OR post_sub.sub = 1
)
);
);

-- Purge context that is no longer relevant to any post

DELETE FROM context_forum_category
WHERE NOT EXISTS (
SELECT NULL FROM notifiable_post WHERE
notifiable_post.context_forum_category_id = context_forum_category.category_id
);

DELETE FROM context_thread
WHERE NOT EXISTS (
SELECT NULL FROM notifiable_post WHERE
notifiable_post.context_thread_id = context_thread.thread_id
);

DELETE FROM context_parent_post
WHERE NOT EXISTS (
SELECT NULL FROM notifiable_post WHERE
notifiable_post.context_parent_post_id = context_parent_post.post_id
);

COMMIT;

0 comments on commit 8404045

Please sign in to comment.