mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-03 23:58:55 +01:00 
			
		
		
		
	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 d977b89af1
Co-authored-by: ghostbear <andreas.everos@gmail.com>
			
			
This commit is contained in:
		@@ -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()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user