db: these changes should make the "db locked" error less likely
All checks were successful
/ check_lfs (push) Successful in 4s
On_Push / lint_fmt (push) Successful in 24s
On_Push / lint_clippy (push) Successful in 1m32s
On_Push / build (push) Successful in 1m39s
On_Push / deploy (push) Successful in 10s

relying more on the underlying storage to keep everything safe
This commit is contained in:
silver 2025-09-19 16:17:29 +01:00
parent 6353d77360
commit 313be247d9
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D

View file

@ -7,10 +7,12 @@ use serenity::{
}, },
prelude::TypeMapKey, prelude::TypeMapKey,
}; };
use sqlx::sqlite::SqliteJournalMode;
use sqlx::{ use sqlx::{
sqlite::{SqliteConnectOptions, SqlitePoolOptions, SqliteRow}, sqlite::{SqliteConnectOptions, SqlitePoolOptions, SqliteRow},
Error, FromRow, Pool, Row, Sqlite, Error, FromRow, Pool, Row, Sqlite,
}; };
use std::time::Duration;
use std::{str::FromStr, sync::Arc}; use std::{str::FromStr, sync::Arc};
pub struct DataBase; pub struct DataBase;
@ -226,7 +228,9 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
.connect_with( .connect_with(
SqliteConnectOptions::from_str(&format!("sqlite://{database}"))? SqliteConnectOptions::from_str(&format!("sqlite://{database}"))?
.foreign_keys(true) .foreign_keys(true)
.create_if_missing(true), .create_if_missing(true)
.journal_mode(SqliteJournalMode::Wal)
.busy_timeout(Duration::from_secs(10)),
) )
.await?; .await?;