Enforce invitation identity at the database level with role-less unique indexes
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with db/schema.rb and the Invitation and WorkshopInvitation model validations to confirm the current role-scoped identity. Review the historical duplicate cleanup prerequisite and PR #2892's token-index migration ordering before changing indexes. Done means role-less unique indexes and matching validations are in place without conflicting concurrent migrations.
Written by the indexing model from the issue text.
Description
Summary
PR #2867 enforces one invitation per member per event/workshop in application code (InvitationManager). The database still encodes the old identity, so nothing prevents a second row — and any future code path (like the one fixed in the review commit for WorkshopsController#find_or_create_invitation) can reintroduce duplicates.
Current state in db/schema.rb:
invitations: unique index on(member_id, event_id, role)— role-inclusive, so it permits one row per roleworkshop_invitations: unique index on(member_id, workshop_id, role)— same problemInvitationandWorkshopInvitationmodel validations:uniqueness: { scope: [..., :role] }
Proposal
- Drop the role-inclusive unique indexes
- Add role-less unique indexes:
(member_id, event_id)oninvitations,(member_id, workshop_id)onworkshop_invitations - Update the model uniqueness validations to match
These indexes also make create_or_find_by race-safe.
Prerequisites
- Historical duplicate rows must be deduped first (companion issue) or index creation fails
- The "which role survives" decision (companion issue) determines what the dedupe keeps
Related
- PR #2892 adds unique token indexes to
invitationsandmeeting_invitations(different column, same tables) — coordinate migration ordering to avoid conflictingalgorithm: :concurrentlyruns
- Dominant language
- Ruby
- Stars
- 104
- Forks
- 205
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 65
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from codebar/planner
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
good first issue performance
Difficulty 3/5 1-2 days Newbie friendliness 78/100
-
performance
Difficulty 4/5 3-5 days Newbie friendliness 58/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100