aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-04-22 03:21:30 -0400
committerAllan Wang <me@allanwang.ca>2019-04-22 03:21:30 -0400
commit7f371a95320a1d8aae29f8ca15f7fd972367b60e (patch)
tree01f5e3f8a03a1030cccb29a29fedb1e9a1bc8350 /app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
parent2fc18d0803c86a3e6892842136e9342dca31a53f (diff)
downloadfrost-7f371a95320a1d8aae29f8ca15f7fd972367b60e.tar.gz
frost-7f371a95320a1d8aae29f8ca15f7fd972367b60e.tar.bz2
frost-7f371a95320a1d8aae29f8ca15f7fd972367b60e.zip
Update parsers and add widget items
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
index e1b1d4c4..67372e23 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
@@ -20,6 +20,7 @@ import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
+import com.pitchedapps.frost.BuildConfig
import org.koin.dsl.module.module
import org.koin.standalone.StandAloneContext
@@ -69,15 +70,22 @@ class FrostDatabase(private val privateDb: FrostPrivateDatabase, private val pub
}
companion object {
+
+ private fun <T : RoomDatabase> RoomDatabase.Builder<T>.frostBuild() = if (BuildConfig.DEBUG) {
+ fallbackToDestructiveMigration().build()
+ } else {
+ build()
+ }
+
fun create(context: Context): FrostDatabase {
val privateDb = Room.databaseBuilder(
context, FrostPrivateDatabase::class.java,
FrostPrivateDatabase.DATABASE_NAME
- ).build()
+ ).frostBuild()
val publicDb = Room.databaseBuilder(
context, FrostPublicDatabase::class.java,
FrostPublicDatabase.DATABASE_NAME
- ).build()
+ ).frostBuild()
return FrostDatabase(privateDb, publicDb)
}