tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
11.22k stars 286 forks source link

disable foreign keys in schema migration #1683

Closed MarinPostma closed 2 months ago

MarinPostma commented 2 months ago

This PR works around disabling foreign_keys being a noop in schema migrations. During the validation of the migration script we allows a prologue and an epilogue of pragmas. If such a prologue is present, we assume that foreign_keys must be disabled for the migration. This is a bit hacky since we don't really validate what pragma is actually being used, but disabling foreign_keys is such a common pattern that assuming it should be ok