Skip to content

Commit 192d407

Browse files
author
Owl Builder
committed
Document SQLite DSN defaults explicitly
The sample environment file now shows the same SQLite DSN shape used by the application default, including shared cache, foreign keys, WAL journaling, normal synchronous mode, and a busy timeout. The config test now pins the generated SQLite DSN exactly so future changes do not silently drop those pragmas. Constraint: SQLite remains the default and OWL_DB_DSN can stay empty to derive from OWL_DB_PATH Confidence: high Scope-risk: narrow Directive: Keep the SQLite example DSN and config.sqliteDSN helper in sync Tested: cd backend && go test ./internal/config Tested: git diff --check
1 parent ee531e4 commit 192d407

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OWL_DB_PATH=/app/data/data.db
1212
#
1313
# SQLite (default): leave OWL_DB_DSN empty to use OWL_DB_PATH, or set an explicit DSN.
1414
# OWL_DB_TYPE=sqlite
15-
# OWL_DB_DSN=file:/app/data/data.db?_fk=1
15+
# OWL_DB_DSN=file:/app/data/data.db?cache=shared&_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_pragma=synchronous(NORMAL)&_pragma=busy_timeout(10000)
1616
#
1717
# PostgreSQL example:
1818
# OWL_DB_TYPE=postgres

backend/internal/config/config_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ func TestLoadDatabaseDefaultsToSQLiteDSN(t *testing.T) {
4646
if cfg.DatabaseDriver != "sqlite3" {
4747
t.Fatalf("expected sqlite3 driver, got %q", cfg.DatabaseDriver)
4848
}
49-
if cfg.DatabaseDSN == "" || cfg.DatabaseDSN == dbPath {
50-
t.Fatalf("expected generated sqlite DSN, got %q", cfg.DatabaseDSN)
49+
expectedDSN := "file:" + dbPath + "?cache=shared&_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_pragma=synchronous(NORMAL)&_pragma=busy_timeout(10000)"
50+
if cfg.DatabaseDSN != expectedDSN {
51+
t.Fatalf("expected generated sqlite DSN %q, got %q", expectedDSN, cfg.DatabaseDSN)
5152
}
5253
}
5354

0 commit comments

Comments
 (0)