From ac4f98e152c66c388dd5f098725f4196df3a7339 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 13 Aug 2022 13:08:16 -0400 Subject: [PATCH] Configure SQLite - Turn on `foreign_keys` to cascade on delete properly - Turn on `journal_mode` and set `synchronous` to NORMAL which may help performance for larger libraries Based on d977b89af1f2a8850437ebd978535fc3fbfd257e Co-authored-by: ghostbear --- .../eu/kanade/tachiyomi/data/database/DbOpenCallback.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt index 31702be039..22b992fec4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt @@ -98,5 +98,14 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) { override fun onConfigure(db: SupportSQLiteDatabase) { db.setForeignKeyConstraintsEnabled(true) + setPragma(db, "foreign_keys = ON") + setPragma(db, "journal_mode = WAL") + setPragma(db, "synchronous = NORMAL") + } + + private fun setPragma(db: SupportSQLiteDatabase, pragma: String) { + val cursor = db.query("PRAGMA $pragma") + cursor.moveToFirst() + cursor.close() } }