Enforce invitation identity at the database level with role-less unique indexes
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
db/schema.rb と Invitation および WorkshopInvitation モデルのバリデーションから始めて、現在のロールスコープ付きの識別情報を確認します。インデックスを変更する前に、過去の重複クリーンアップの前提条件と PR #2892 の token-index マイグレーションの順序を確認します。ロールなしの一意インデックスと対応するバリデーションが、競合する並行マイグレーションなしで配置されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Ruby
- スター
- 104
- フォーク
- 205
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 65
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codebar/planner のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
good first issue performance
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
-
performance
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
codebar/planner の issue をすべて見る
似ている issue
-
user-reported
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
Kong/developer.konghq.com#7316 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TheOdinProject/curriculum#31408 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
notch8/utk_knapsack#148 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
Homebrew/homebrew-cask#288729 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100