fix: Bounty.issue FK from CASCADE to RESTRICT - #239
Merged
chonilius merged 1 commit intoAug 27, 2026
Merged
Conversation
…tion convention bounties.issueId was ON DELETE CASCADE, unlike every other financial-adjacent relation on Bounty (sponsor/claimedBy/team use SET NULL) and unlike the escrow/payment FKs fixed in MergeFi#27's EscrowFkIntegrityAndSponsorId migration (SET NULL/RESTRICT). Deleting an Issue must never silently delete its Bounty, which may reference a funded Escrow. issueId is NOT NULL so RESTRICT (not SET NULL) is the correct action here. Closes MergeFi#53 Closes MergeFi#21 Closes MergeFi#52 Closes MergeFi#23
|
@Williams-1604 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
bounties.issueId's foreign key wasON DELETE CASCADE— the onlyCASCADEamong Bounty's relations. Every other one (sponsor,claimedBy,team) usesSET NULL, and #27'sEscrowFkIntegrityAndSponsorIdmigration already established the convention that financial-adjacent rows (escrows, payments) must never cascade-delete — a Bounty may reference a fundedEscrow, so deleting its parentIssuemust not silently delete it too.Changes
bounty.entity.ts:issuerelationonDeletechangedCASCADE→RESTRICT(issueIdisNOT NULL, soSET NULLisn't valid here —RESTRICTmirrors thepayments.escrowIdpattern from Sponsor dashboard aggregate figures (total spend, budget locked in escrow) can be computed from stale/incorrect data due to missing FK integrity constraints #27)BountyIssueFkRestrict1785000000000: re-points the existing FK constraint in place, reusing the samereplaceForeignKeyOnDeletehelper pattern from Sponsor dashboard aggregate figures (total spend, budget locked in escrow) can be computed from stale/incorrect data due to missing FK integrity constraints #27's migration (looks up the constraint name viapg_constraintrather than hardcoding it)Closes #53
Closes #21
Closes #52
Closes #23