fix(V2): add cascade deletes for mid-chain verification and issuance endpoints#1571
Merged
Merged
Conversation
…endpoints DELETE /v2/verification/:id and DELETE /v2/issuance/:id previously staged only the parent row, orphaning downstream children (issuances, units, unit_labels). This mirrors the cascade logic already present on project and unit deletes. Adds stageVerificationChildDeletes and stageIssuanceChildDeletes helpers, wires them into their respective controllers with transaction + mutex, and documents the two-category deletion design (project-scoped cascade vs shared-record guard) in v2-cascade-delete.js. Integration tests cover both mid-chain cascades, double-delete idempotency, and multi-unit-per-issuance. Live API test batches all three cascade levels (unit, issuance, verification) into one commit cycle to avoid adding test runtime.
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.
Summary
DELETE /v2/verification/:idnow cascades to issuances → units → unit_labels, andDELETE /v2/issuance/:idnow cascades to units → unit_labels. Previously only the parent row was staged, leaving downstream records orphaned in the datalayer.stageVerificationChildDeletesandstageIssuanceChildDeletestov2-cascade-delete.js, mirroring the existing project and unit cascade patterns (transaction + mutex).Test plan
Integration tests (all new, run via
npm run test:v2)stagedChildDeletes === 0stagedChildDeletes === 0Live API tests (run via
npm run test:v2:live:cascade-delete)Note
Medium Risk
Modifies V2 deletion staging for
verificationandissuanceto add transactional cascade behavior; mistakes could over/under-delete staged records or impact DataLayer sync ordering, but scope is limited to delete paths and is covered by new integration/live tests.Overview
Fixes mid-chain delete staging for V2
verificationandissuance.DELETE /v2/verification/:idnow also stages deletes for downstreamissuance → unit → unit_label, andDELETE /v2/issuance/:idnow stagesunit → unit_labeldeletes to prevent orphaned children.Deletes are now staged under the existing V2 mutex +
sequelizeV2.transaction, and responses includestagedChildDeletesfor visibility. Adds new cascade helpers (stageVerificationChildDeletes,stageIssuanceChildDeletes) plus expanded integration and live API coverage for multi-child cascades, no-children cases, and documenting current double-delete-before-commit behavior.Reviewed by Cursor Bugbot for commit dcdb60f. Bugbot is set up for automated code reviews on this repo. Configure here.