handle DB foreign key constraint for ModLog entries

This commit is contained in:
Hendrik L 2024-12-03 17:07:19 +01:00
parent f98e8eaf5a
commit 23a6b2673e

View file

@ -631,6 +631,7 @@ class Community(db.Model):
db.session.query(CommunityJoinRequest).filter(CommunityJoinRequest.community_id == self.id).delete() 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(CommunityMember).filter(CommunityMember.community_id == self.id).delete()
db.session.query(Report).filter(Report.suspect_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', 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(PollChoiceVote).filter(PollChoiceVote.user_id == self.id).delete()
db.session.query(PostBookmark).filter(PostBookmark.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(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): def purge_content(self, soft=True):
files = File.query.join(Post).filter(Post.user_id == self.id).all() files = File.query.join(Post).filter(Post.user_id == self.id).all()