Skip to content

Fix: TeamMemberSplit Referential Integrity (Issue #58) - #82

Open
gramseostudio-dev wants to merge 1 commit into
MergeFi:mainfrom
gramseostudio-dev:main
Open

Fix: TeamMemberSplit Referential Integrity (Issue #58)#82
gramseostudio-dev wants to merge 1 commit into
MergeFi:mainfrom
gramseostudio-dev:main

Conversation

@gramseostudio-dev

Copy link
Copy Markdown
Contributor

Closes #58

Problem Description

User deletion was configured with onDelete: 'CASCADE' on the TeamMemberSplit entity. This caused that if a user was deleted (e.g., account closure), their record in the team split configuration silently disappeared. This broke the business invariant where team split percentages must sum exactly to 100%, leaving bounties linked to that team stuck in a MERGED state without the ability to release the escrow (stuck MERGED bounty).

Applied Changes

  • Entity: Changed the TeamMemberSplit.user relation from onDelete: 'CASCADE' to onDelete: 'RESTRICT'. This ensures the database blocks user deletion if they still have active financial commitments in a team.
  • Migration: Created migration 1784600000000-UpdateTeamMemberSplitOnDelete to update the foreign key constraint on the team_member_splits table.
  • Test: Added an integration test (test/team-split-integrity.e2e-spec.ts) that empirically verifies that deleting a user with active team memberships is successfully blocked by the database constraint.

Design Notes / Considerations

The choice of RESTRICT aligns with the established policy of other financial entities in the system (such as Payment.escrow). We recognize that this blocks legitimate user account deletions if they belong to an active team. We consider this a necessary safeguard for current financial integrity. It is our team's commitment to implement a future soft-delete or team membership deactivation mechanism, allowing users to "leave" older teams without needing to wipe their user record and without breaking foreign key restrictions.

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

@gramseostudio-dev 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