fix: set durability for sqlite to recommended settings (#1667)

Also do an optimize on connection close. Fixes lag on history insertion.
This commit is contained in:
Joe Ardent 2024-02-04 10:42:48 -08:00 committed by GitHub
parent c2af6f7ae8
commit b7bb583d8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,7 +14,10 @@ use rand::{distributions::Alphanumeric, Rng};
use regex::Regex;
use sql_builder::{esc, quote, SqlBuilder, SqlName};
use sqlx::{
sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqlitePoolOptions, SqliteRow},
sqlite::{
SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqlitePoolOptions, SqliteRow,
SqliteSynchronous,
},
Result, Row,
};
use time::OffsetDateTime;
@ -137,6 +140,8 @@ impl Sqlite {
let opts = SqliteConnectOptions::from_str(path.as_os_str().to_str().unwrap())?
.journal_mode(SqliteJournalMode::Wal)
.optimize_on_close(true, None)
.synchronous(SqliteSynchronous::Normal)
.create_if_missing(true);
let pool = SqlitePoolOptions::new()