Fix: Implement cascade delete for claims and claim reviews to ensure data integrity#2271
Merged
caneppelevitor merged 10 commits intostagefrom Mar 2, 2026
Merged
Conversation
caneppelevitor
requested changes
Feb 27, 2026
caneppelevitor
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary of the changes
This PR implements a robust cascade soft delete functionality for the Personality and Claim hierarchy, migrating orchestration logic to a new
ManagementModuleto avoid circular dependencies.Key Changes
ManagementControllerandManagementServiceto handle cascade deletion for both Personalities (Personality -> Claims -> ClaimReviews) and Claims (Claim -> ClaimReviews).ClaimReview.listAllwith aggregation and its own count.countDocumentsbased on the query.Claim.listAllto include its own count for accurate totals, avoiding inconsistencies with previous global count.ClaimServiceandPersonalityService.PersonalityService.getByIdanddeletemethods to fix E2E test failures and ensure accurate history logging.ClaimReviewServiceand implementedfindPublishedReviewsByClaimIdfor precise data retrieval.ObjectIds.ManagementServiceandManagementController, covering success scenarios,NotFoundException, invalid ID formats, and unexpected errors.Related Ticket #2265
👉 View Evidence on Notion
Type of change
Testing
Relevant Testing Instructions
npm run testto execute the new unit tests forManagementServiceandManagementController.npm run test:e2eto ensure the cascade delete functionality integrates correctly with the database and authentication guards.isDeleted: true) and history records are created.Scenarios Impacted
Personalityrecords (now removes associatedClaimsandClaimReviews).Claimrecords (now removes associatedClaimReviews).ClaimReviewsandClaims:ClaimReview.listAllusing its own aggregation and count logic for consistency.countDocumentscount for use in Home stats.Claim.listAllwith its own count to fix inconsistencies between listed items and total count.Developer Checklist
General
console.logor related logging is added.Frontend Changes
Backend Changes
Tests
Test IDs
Merge Request Review Checklist