diff --git a/request-filterer/request-filterer-impl/build.gradle b/request-filterer/request-filterer-impl/build.gradle index 2fa8bdcb616c..f9052652cf7b 100644 --- a/request-filterer/request-filterer-impl/build.gradle +++ b/request-filterer/request-filterer-impl/build.gradle @@ -35,6 +35,7 @@ dependencies { implementation project(':request-filterer-store') implementation project(':browser-api') implementation project(':statistics-api') + implementation project(':data-store-api') implementation "com.squareup.logcat:logcat:_" implementation Square.retrofit2.converter.moshi diff --git a/request-filterer/request-filterer-impl/src/main/java/com/duckduckgo/request/filterer/impl/di/RequestFiltererModule.kt b/request-filterer/request-filterer-impl/src/main/java/com/duckduckgo/request/filterer/impl/di/RequestFiltererModule.kt index 4b245108e91f..0d9981cdd6b3 100644 --- a/request-filterer/request-filterer-impl/src/main/java/com/duckduckgo/request/filterer/impl/di/RequestFiltererModule.kt +++ b/request-filterer/request-filterer-impl/src/main/java/com/duckduckgo/request/filterer/impl/di/RequestFiltererModule.kt @@ -17,10 +17,11 @@ package com.duckduckgo.request.filterer.impl.di import android.content.Context -import androidx.room.Room import com.duckduckgo.app.di.AppCoroutineScope import com.duckduckgo.app.di.IsMainProcess import com.duckduckgo.common.utils.DispatcherProvider +import com.duckduckgo.data.store.api.DatabaseProvider +import com.duckduckgo.data.store.api.RoomDatabaseConfig import com.duckduckgo.di.scopes.AppScope import com.duckduckgo.request.filterer.store.ALL_MIGRATIONS import com.duckduckgo.request.filterer.store.RealRequestFiltererFeatureToggleRepository @@ -40,13 +41,17 @@ import kotlinx.coroutines.CoroutineScope @ContributesTo(AppScope::class) object RequestFiltererModule { - @SingleInstanceIn(AppScope::class) @Provides - fun provideRequestFiltererDatabase(context: Context): RequestFiltererDatabase { - return Room.databaseBuilder(context, RequestFiltererDatabase::class.java, "request_filterer.db") - .fallbackToDestructiveMigration() - .addMigrations(*ALL_MIGRATIONS) - .build() + @SingleInstanceIn(AppScope::class) + fun provideRequestFiltererDatabase(databaseProvider: DatabaseProvider): RequestFiltererDatabase { + return databaseProvider.buildRoomDatabase( + RequestFiltererDatabase::class.java, + "request_filterer.db", + config = RoomDatabaseConfig( + fallbackToDestructiveMigration = true, + migrations = ALL_MIGRATIONS, + ), + ) } @SingleInstanceIn(AppScope::class) diff --git a/request-filterer/request-filterer-store/src/main/java/com/duckduckgo/request/filterer/store/RequestFiltererDatabase.kt b/request-filterer/request-filterer-store/src/main/java/com/duckduckgo/request/filterer/store/RequestFiltererDatabase.kt index 5568dca414c8..1c62254c6d6f 100644 --- a/request-filterer/request-filterer-store/src/main/java/com/duckduckgo/request/filterer/store/RequestFiltererDatabase.kt +++ b/request-filterer/request-filterer-store/src/main/java/com/duckduckgo/request/filterer/store/RequestFiltererDatabase.kt @@ -32,4 +32,4 @@ abstract class RequestFiltererDatabase : RoomDatabase() { abstract fun requestFiltererDao(): RequestFiltererDao } -val ALL_MIGRATIONS = emptyArray() +val ALL_MIGRATIONS = emptyList()