Enable foreign keys by default when opening the database

This commit is contained in:
2025-09-27 10:39:49 +02:00
parent 0a50f252a4
commit 0da40c6659
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -14473,6 +14473,13 @@ int cweb_enable_database(CWEB *cweb, CWEB_String database_file, CWEB_String sche
return -1; return -1;
} }
ret = sqlite3_exec(cweb->db, "PRAGMA foreign_keys = ON;", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
sqlite3_close(cweb->db);
cweb->db = NULL;
return -1;
}
LoadedFile *schema = load_file(schema_file); LoadedFile *schema = load_file(schema_file);
if (schema == NULL) { if (schema == NULL) {
sqlite3_close(cweb->db); sqlite3_close(cweb->db);
+7
View File
@@ -1061,6 +1061,13 @@ int cweb_enable_database(CWEB *cweb, CWEB_String database_file, CWEB_String sche
return -1; return -1;
} }
ret = sqlite3_exec(cweb->db, "PRAGMA foreign_keys = ON;", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
sqlite3_close(cweb->db);
cweb->db = NULL;
return -1;
}
LoadedFile *schema = load_file(schema_file); LoadedFile *schema = load_file(schema_file);
if (schema == NULL) { if (schema == NULL) {
sqlite3_close(cweb->db); sqlite3_close(cweb->db);