PRAGMA foreign keys = ON;
See original GitHub issueHow can I activate foreign keys check before performing an Insert ? I’ve tried
knex.raw('PRAGMA foreign keys = ON;');
But it’s not working.
Any thoughts ?
Thanks !
Issue Analytics
- State:
- Created 9 years ago
- Reactions:4
- Comments:14 (4 by maintainers)
Top Results From Across the Web
SQLite Foreign Key Support
Foreign key ON DELETE and ON UPDATE clauses are used to configure actions that take place when deleting rows from the parent table...
Read more >SQLite Foreign Key: Enforce Relationships Between Tables
If the SQLite library is compiled with foreign key constraint support, the application can use the PRAGMA foreign_keys command to enable or disable...
Read more >SQLite: pragma foreign_keys
pragma foreign_keys = on enforces foreign keys. This is usually necessary because by default, SQLite does not enforce foreign keys.
Read more >SQLite3 "forgets" to use foreign keys - Stack Overflow
I know that foreign keys are deactivated by default and have to be activated with PRAGMA foreign_keys = ON; . In my Ruby...
Read more >foreign_key_list - Using SQLite [Book] - O'Reilly
The foreign_key_list pragma lists all the foreign key references that are part of the specified table. That list will contain one row for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So, the code there doesn’t actually do anything, as the db calls are async and it’s never executed with
.exec
or.then
(or related promise methods). What you want to do is add anafterCreate
on the pool and run one of the api’s for the sqlite3 as needed:That being said, I realized recently that the
foreign_keys
pragma being off by default in sqlite3 is a bit inconsistent. @vschoettke or @bendrucker, what do you think about changing this to be run by default (configurable to turn off in the config options) so foreign keys are consistent with the other databases.+1 totally got me by surprise that SQLite has it off by default