diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2025-02-22 14:06:20 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2025-02-22 14:06:20 -0500 |
commit | 4221780ce53ff7484f6f1958173373dc963e7967 (patch) | |
tree | a9295bcc6161b97d33256b069ea3a5c8fe35e5ff /internal/db/setup.go | |
parent | f36f77472a82d6ebfac153aed6d17f154ae239a6 (diff) |
functional scratch dockerfile
Diffstat (limited to 'internal/db/setup.go')
-rw-r--r-- | internal/db/setup.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/db/setup.go b/internal/db/setup.go index 038334a..ff56233 100644 --- a/internal/db/setup.go +++ b/internal/db/setup.go @@ -10,7 +10,7 @@ import ( "strings" "time" - _ "github.com/mattn/go-sqlite3" + _ "modernc.org/sqlite" ) var ( @@ -73,7 +73,7 @@ func Setup(ctx context.Context, path string) (*Store, error) { return new(db) } - db, err := sql.Open("sqlite3", path+opts()) + db, err := sql.Open("sqlite", path+opts()) if err != nil { slog.ErrorContext(ctx, "failed to open DB", "error", err) backupFile(ctx, path) @@ -84,6 +84,16 @@ func Setup(ctx context.Context, path string) (*Store, error) { return new(db) } + _, err = db.Exec("PRAGMA foreign_keys = ON") + if err != nil { + return nil, err + } + + _, err = db.Exec("PRAGMA journal_mode=WAL") + if err != nil { + return nil, err + } + // Run integrity check. var integrity string if err = db.QueryRow("PRAGMA integrity_check;").Scan(&integrity); err != nil || integrity != "ok" { |