mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-21 22:16:18 +00:00
simplify pragma sqlite
This commit is contained in:
parent
81468d6131
commit
b843f0ea94
4 changed files with 3 additions and 18 deletions
|
@ -10,12 +10,9 @@ let db = null;
|
|||
export function getDb() {
|
||||
if (db) return db;
|
||||
const sqlite = new Database(DB_PATH);
|
||||
sqlite.exec(`PRAGMA journal_mode = WAL;`);
|
||||
sqlite.exec(`PRAGMA busy_timeout = 15000;`);
|
||||
sqlite.exec(`PRAGMA synchronous = NORMAL;`);
|
||||
sqlite.exec(`PRAGMA cache_size = 1000000000;`);
|
||||
sqlite.exec(`PRAGMA foreign_keys = true;`);
|
||||
sqlite.exec(`PRAGMA temp_store = memory;`);
|
||||
sqlite.pragma(`journal_mode = WAL`);
|
||||
sqlite.pragma(`busy_timeout = 15000`);
|
||||
sqlite.pragma(`foreign_keys = true`);
|
||||
db = drizzle(sqlite, { schema, logger: true });
|
||||
migrateDb(db);
|
||||
return db;
|
||||
|
|
|
@ -14,9 +14,6 @@ export function migrateDb(db) {
|
|||
path = "node_modules/db-datos/drizzle";
|
||||
migrate(db, { migrationsFolder: path });
|
||||
db.run(sql`pragma journal_mode = WAL;`);
|
||||
db.run(sql`PRAGMA synchronous = NORMAL;`);
|
||||
db.run(sql`PRAGMA busy_timeout = 15000;`);
|
||||
db.run(sql`PRAGMA cache_size = 1000000000;`);
|
||||
// db.run(sql`PRAGMA foreign_keys = true;`);
|
||||
db.run(sql`PRAGMA temp_store = memory;`);
|
||||
}
|
||||
|
|
|
@ -107,11 +107,7 @@ async fn main() {
|
|||
))
|
||||
.unwrap()
|
||||
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
|
||||
.pragma("journal_size_limit", "67108864")
|
||||
.pragma("mmap_size", "134217728")
|
||||
.synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
|
||||
.busy_timeout(Duration::from_secs(15))
|
||||
.pragma("cache_size", "2000")
|
||||
.optimize_on_close(true, None),
|
||||
)
|
||||
.await
|
||||
|
|
|
@ -115,12 +115,7 @@ async fn connect_to_db(
|
|||
SqliteConnectOptions::from_str(&format!("sqlite://{}", db_path))?
|
||||
// https://fractaledmind.github.io/2023/09/07/enhancing-rails-sqlite-fine-tuning/
|
||||
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
|
||||
.pragma("journal_size_limit", "67108864")
|
||||
.pragma("mmap_size", "134217728")
|
||||
.synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
|
||||
.busy_timeout(Duration::from_secs(15))
|
||||
.pragma("cache_size", "2000")
|
||||
.pragma("temp_store", "memory")
|
||||
.optimize_on_close(true, None),
|
||||
)
|
||||
.await?)
|
||||
|
|
Loading…
Reference in a new issue