Hello there,
I've just started with node-sqlite3 (first time with sql as well) and I've been having some errors that lead me thinking about foreign key support, and then I found the following post on the sqlite foreign key support page, and I couldn't find any information regarding it here.
So, is there anything that I need to do regarding the foreign key support?
In order to use foreign key constraints in SQLite, the library must be compiled with neither SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined. If SQLITE_OMIT_TRIGGER is defined but SQLITE_OMIT_FOREIGN_KEY is not, then SQLite behaves as it did prior to version 3.6.19 (2009-10-14) - foreign key definitions are parsed and may be queried using PRAGMA foreign_key_list, but foreign key constraints are not enforced. The PRAGMA foreign_keys command is a no-op in this configuration. If OMIT_FOREIGN_KEY is defined, then foreign key definitions cannot even be parsed (attempting to specify a foreign key definition is a syntax error).
It seems like it's not enabled by default, but you can enable it by running:
db.get("PRAGMA foreign_keys = ON")
Thanks! :)
@literallylara @mnemanja where i put this option in my code or what object of knex has this function get? I tried but don't get success.
Most helpful comment
It seems like it's not enabled by default, but you can enable it by running: