From dff70670ef804454a68cb5c854f7fe88ac7024ac Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Tue, 26 Dec 2023 16:17:18 +0100 Subject: [PATCH] fk --- mapobjectdb/sqlite/migrations/01_init.up.sql | 1 - mapobjectdb/sqlite/new.go | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mapobjectdb/sqlite/migrations/01_init.up.sql b/mapobjectdb/sqlite/migrations/01_init.up.sql index 15e4ed65..585086cb 100644 --- a/mapobjectdb/sqlite/migrations/01_init.up.sql +++ b/mapobjectdb/sqlite/migrations/01_init.up.sql @@ -1,4 +1,3 @@ -PRAGMA foreign_keys = ON; PRAGMA journal_mode = MEMORY; create table if not exists objects( diff --git a/mapobjectdb/sqlite/new.go b/mapobjectdb/sqlite/new.go index 4aeb5b9c..ef512af1 100644 --- a/mapobjectdb/sqlite/new.go +++ b/mapobjectdb/sqlite/new.go @@ -8,8 +8,12 @@ import ( func New(filename string) (*Sqlite3Accessor, error) { db, err := sql.Open("sqlite", filename+"?_timeout=500") - db.SetMaxOpenConns(1) + if err != nil { + return nil, err + } + db.SetMaxOpenConns(1) + _, err = db.Exec("PRAGMA foreign_keys = ON") if err != nil { return nil, err }