Cascade delete kills child records
Your task
An engineer ran an approved cleanup at 15:30 to delete ~2,000 stale projects rows for a churned customer cohort. The query ran in seconds and looked correct. Within minutes, support floods in: thousands of active customers report their tasks, comments, and attachments are gone. Dashboards: no errors, DB healthy, but row counts on several child tables dropped by millions. A migration last quarter added ON DELETE CASCADE foreign keys from those child tables to projects. How do you triage, stop further loss, and recover?
It covers
- Cascade delete
- Foreign key
- Cleanup script
- Blast radius