fix(forum): Delete dependent records before removing reply
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Explicitly delete reply reads, attachments, reports and edit history before deleting the reply to avoid NotNullViolation on forum_reply_reads. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8de78e14a1
commit
48b42eb8b1
@ -586,6 +586,11 @@ def admin_forum_delete_reply(reply_id):
|
||||
return jsonify({'success': False, 'error': 'Odpowiedź nie istnieje'}), 404
|
||||
|
||||
topic_id = reply.topic_id
|
||||
# Delete dependent records first (reply reads, attachments, reports, edit history)
|
||||
db.query(ForumReplyRead).filter(ForumReplyRead.reply_id == reply_id).delete()
|
||||
db.query(ForumAttachment).filter(ForumAttachment.reply_id == reply_id).delete()
|
||||
db.query(ForumReport).filter(ForumReport.reply_id == reply_id).delete()
|
||||
db.query(ForumEditHistory).filter(ForumEditHistory.reply_id == reply_id).delete()
|
||||
db.delete(reply)
|
||||
db.commit()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user