Skip to content

fix(teams): change TeamMemberSplit.user onDelete from CASCADE to RESTRICT (#58) - #70

Open
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/58-team-member-split-fk-restrict
Open

fix(teams): change TeamMemberSplit.user onDelete from CASCADE to RESTRICT (#58)#70
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/58-team-member-split-fk-restrict

Conversation

@ghzhost

@ghzhost ghzhost commented Aug 16, 2026

Copy link
Copy Markdown

Overview

Closes #58.

This PR fixes a critical data-integrity gap where used . When a account was deleted, TypeORM/Postgres would cascade the deletion to remove their row outright, silently leaving the remaining team splits summing to less than 100%. Subsequent calls to would pass the invalid splits to , causing to throw a and stranding the bounty permanently in with a escrow.

Changes Made

  1. Entity Definition: Changed relation from to , treating team member splits as financial commitments that must not be silently removed.
  2. Database Migration: Added using the established helper to safely update the live foreign key constraint on without hardcoding TypeORM constraint names.
  3. Unit Tests: Added comprehensive test suite testing team creation, split percentage validation, , and .

Deletion Policy Trade-off Analysis

  • Why RESTRICT: A is a financial commitment (a promised percentage of a bounty payout) in the same sense that a is a record of moved funds. Using guarantees database-level enforcement of the 100% split invariant.
  • Account Deletion / GDPR: If a user genuinely requests account removal, their user record cannot be hard-deleted while bound to active team commitments. Instead, once bounties are finalized or if soft-delete/anonymization is performed (e.g. clearing PII fields while retaining the UUID foreign key), data integrity remains fully preserved.

Validation

  • : Compiles successfully with no TypeScript errors.
  • : All 116 tests passing across 17 test suites.

…RICT (MergeFi#58)

- Update TeamMemberSplit.user relation onDelete to 'RESTRICT' to preserve team percentage invariants
- Add migration TeamMemberSplitFkRestrict1784500000000 replacing FK constraint with RESTRICT
- Add unit tests for TeamsService covering team creation, validation and bounty assignment
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant