From f316c6a23317701ae9fe2c097c55140dea655cfc Mon Sep 17 00:00:00 2001 From: Thomas Karpiniec Date: Sat, 19 Oct 2024 14:31:10 +1100 Subject: [PATCH 1/1] Add suitable pragmas for sqlite --- .gitignore | 2 +- server/database.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 97571d1..c2f7731 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ broadcaster-server broadcaster-radio test-server.conf test-radio.conf -test.db +test.db* diff --git a/server/database.go b/server/database.go index e6ce752..d6bbf92 100644 --- a/server/database.go +++ b/server/database.go @@ -21,10 +21,19 @@ func InitDatabase() { } db.sqldb = sqldb + _, err = db.sqldb.Exec("PRAGMA journal_mode = WAL") + if err != nil { + log.Fatal(err) + } + _, err = db.sqldb.Exec("PRAGMA foreign_keys = ON") if err != nil { - log.Printf("%q\n", err) - return + log.Fatal(err) + } + + _, err = db.sqldb.Exec("PRAGMA busy_timeout = 5000") + if err != nil { + log.Fatal(err) } sqlStmt := ` -- 2.39.5