Commit 9bc5b97
committed
fix(promo-codes): harden reservation backfill per Codex review
Three no-behavior-change safety nits from the step-1 audit:
- Version20260415191522 backfill now uses GREATEST(QtyUsed, VALUES(QtyUsed))
on the ON DUPLICATE KEY path so a re-run after live saga writes can
never clobber a newer counter with a stale historical count.
- Version20260415191522.down() is now a documented no-op. The previous
TRUNCATE would have silently zeroed live counters once step 2 lands.
Roll back Version20260415191521 if a clean slate is needed.
- ISummitPromoCodeMemberReservationRepository docblock is reworded so
the 'outer lock' statement is explicit as a CALLER PRECONDITION,
not something the repository guarantees or enforces.
Migration down/up round-trip re-verified on docker MySQL.
Remaining step-1 concern — undo idempotency of the entity's decrement
helper — is deferred to step 2, where the saga caller is the right
place to guard duplicate undo invocations (mirror the 'redeem' flag
pattern already used by ApplyPromoCodeTask::undo).1 parent b1f3abe commit 9bc5b97
2 files changed
Lines changed: 14 additions & 10 deletions
File tree
- app/Models/Foundation/Summit/Repositories
- database/migrations/model
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
0 commit comments