Mechanism◆Article
Because PRAGMA foreign_keys cannot be changed inside an open transaction, dropping the old table as part of table.transform() could previously fire destructive ON DELETE actions and silently delete or modify rows that referenced that table.
The bug arose because the foreign_keys pragma can't be toggled mid-transaction, so the table drop inside transform() could unintentionally cascade-delete or modify referencing rows. ✦ AI generated
Simon Willison · Simon Willison's Weblog · 2026-07-12 · original ↗
The pragma cannot be changed inside a transaction, so previously dropping the old table as part of the transform could fire those actions and silently delete or modify referencing rows.
Read full article ↗excerpt · fair-use quotation
- ·PRAGMA foreign_keys can't change inside a transaction
- ·transform() drops the old table mid-transaction
- ·Old FK-cascade rules stayed active during the drop
- ·Could silently delete or modify referencing rows
- ·ON DELETE actions fired unintentionally on drop
- ·Rows referencing the table vanished or changed silently
- ·No error raised — data loss went unnoticed
- ·Root cause: pragma toggling restricted mid-transaction
Around this claim