Use WAL mode

This commit is contained in:
Jan Zípek 2024-03-31 18:48:28 +02:00
parent aca2e8778c
commit f1cb72ccc8
Signed by: kamen
GPG Key ID: A17882625B33AC31
2 changed files with 8 additions and 0 deletions

2
server/.gitignore vendored
View File

@ -2,4 +2,6 @@
basic-sensor-receiver.exe basic-sensor-receiver.exe
basic-sensor-receiver basic-sensor-receiver
*.sqlite3 *.sqlite3
*.sqlite3-shm
*.sqlite3-wal
tmp/ tmp/

View File

@ -13,6 +13,12 @@ func Initialize(databaseUrl string) (*sql.DB, error) {
return nil, fmt.Errorf("failed to open database connection: %w", err) return nil, fmt.Errorf("failed to open database connection: %w", err)
} }
_, err = db.Exec(`PRAGMA journal_mode=WAL;`)
if err != nil {
return nil, fmt.Errorf("failed to set journal mode: %w", err)
}
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS migrations ( _, err = db.Exec(`CREATE TABLE IF NOT EXISTS migrations (
id TEXT NOT NULL, id TEXT NOT NULL,
run_at INTEGER NOT NULL run_at INTEGER NOT NULL