Commit e04782e
fix(billing): pending_checkouts ON DELETE CASCADE (mig 069) — unblock team reap (#272)
053_pending_checkouts created the team_id FK without ON DELETE CASCADE — the ONLY
team-child table missing it. DeleteTeamHard (the e2e-account reap) and the worker
team_deletion_executor delete a team with a bare DELETE FROM teams and rely on
children cascading, so a team that ever started a checkout (→ a pending_checkouts
row) failed:
pq: ... violates foreign key constraint "pending_checkouts_team_id_fkey"
This surfaced live the moment test-cohort checkout was armed: a cohort Pro upgrade
creates a pending_checkouts row, so the reap 503'd (db_failed) and the cohort team
LEAKED — breaking the rule-24 'cohort data is always reaped' guarantee. Found by
the real test-card payment run.
Migration 069 aligns the FK with every other team-child table (ON DELETE CASCADE),
idempotent (DROP IF EXISTS + re-ADD). Already applied live; this codifies it.
Test: TestDeleteTeamHard_CascadesPendingCheckouts seeds a pending_checkouts row
and asserts DeleteTeamHard cascades it instead of erroring.
Co-authored-by: Claude <noreply@anthropic.com>1 parent 232a991 commit e04782e
2 files changed
Lines changed: 64 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
80 | 116 | | |
81 | 117 | | |
82 | 118 | | |
| |||
0 commit comments