From 23a6b2673eb95fb614da55450d8cacb6f4f56aca Mon Sep 17 00:00:00 2001 From: Hendrik L Date: Tue, 3 Dec 2024 17:07:19 +0100 Subject: [PATCH] handle DB foreign key constraint for ModLog entries --- app/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models.py b/app/models.py index 2e903196..795e059f 100644 --- a/app/models.py +++ b/app/models.py @@ -631,6 +631,7 @@ class Community(db.Model): db.session.query(CommunityJoinRequest).filter(CommunityJoinRequest.community_id == self.id).delete() db.session.query(CommunityMember).filter(CommunityMember.community_id == self.id).delete() db.session.query(Report).filter(Report.suspect_community_id == self.id).delete() + db.session.query(ModLog).filter(ModLog.community_id == self.id).delete() user_role = db.Table('user_role', @@ -1021,6 +1022,7 @@ class User(UserMixin, db.Model): db.session.query(PollChoiceVote).filter(PollChoiceVote.user_id == self.id).delete() db.session.query(PostBookmark).filter(PostBookmark.user_id == self.id).delete() db.session.query(PostReplyBookmark).filter(PostReplyBookmark.user_id == self.id).delete() + db.session.query(ModLog).filter(ModLog.user_id == self.id).delete() def purge_content(self, soft=True): files = File.query.join(Post).filter(Post.user_id == self.id).all()