Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

But, last I checked, you could PRAGMA foreign_keys=off temporarily, which would also inhibit the automatic handling of foreign key constraints in other tables when the target table is renamed or dropped. Then you can create a new table, populate it, drop the old one, rename the new one to the old name, and turn foreign_keys back on, and the constraints will now target the new table.


Does that actually work for dropping and renaming tables? I thought I tried that.


In any event you can get the foreign keys from sqlite_master, delete them during the reorganisation and then put them back afterwards.


It does in 3.7.13 (and presumably older versions, but I don't have a solid record of this immediately available).




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: