Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/main/java/com/duckduckgo/app/di/DatabaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.app.di
import android.content.Context
import android.webkit.WebViewDatabase
import androidx.room.Room
import androidx.room.RoomDatabase
import com.duckduckgo.app.browser.addtohome.AddToHomeCapabilityDetector
import com.duckduckgo.app.browser.httpauth.RealWebViewHttpAuthStore
import com.duckduckgo.app.browser.httpauth.WebViewHttpAuthStore
Expand Down Expand Up @@ -53,6 +54,8 @@ class DatabaseModule {
return Room.databaseBuilder(context, AppDatabase::class.java, "app.db")
.addMigrations(*migrationsProvider.ALL_MIGRATIONS.toTypedArray())
.addCallback(migrationsProvider.BOOKMARKS_DB_ON_CREATE)
.addCallback(migrationsProvider.CHANGE_JOURNAL_ON_OPEN)
.setJournalMode(RoomDatabase.JournalMode.TRUNCATE)
.build()
}

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/duckduckgo/app/global/db/AppDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ class MigrationsProvider(
}
}

val CHANGE_JOURNAL_ON_OPEN = object : RoomDatabase.Callback() {
override fun onOpen(db: SupportSQLiteDatabase) {
db.query("PRAGMA journal_mode=DELETE;").use { cursor -> cursor.moveToFirst() }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pragma for the win

}
}

val ALL_MIGRATIONS: List<Migration>
get() = listOf(
MIGRATION_1_TO_2,
Expand Down