diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 01be62a5..190ed2ec 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -15,6 +15,7 @@ -keep class com.google.gson.reflect.TypeToken -keep class * extends com.google.gson.reflect.TypeToken -# Keep room database and entities --keep class * extends androidx.room.RoomDatabase --keep @androidx.room.Entity class * +# Keep user preferences enums +-keep public enum dev.shorthouse.coinwatch.data.datastore.**{ + *; +} diff --git a/app/src/main/java/dev/shorthouse/coinwatch/data/source/local/CoinDatabase.kt b/app/src/main/java/dev/shorthouse/coinwatch/data/source/local/CoinDatabase.kt index 86ba75a9..9adb355c 100644 --- a/app/src/main/java/dev/shorthouse/coinwatch/data/source/local/CoinDatabase.kt +++ b/app/src/main/java/dev/shorthouse/coinwatch/data/source/local/CoinDatabase.kt @@ -1,5 +1,6 @@ package dev.shorthouse.coinwatch.data.source.local +import androidx.room.AutoMigration import androidx.room.Database import androidx.room.RoomDatabase import androidx.room.TypeConverters @@ -10,9 +11,11 @@ import dev.shorthouse.coinwatch.data.source.local.model.CachedCoin import dev.shorthouse.coinwatch.data.source.local.model.FavouriteCoin @Database( + version = 2, entities = [FavouriteCoin::class, CachedCoin::class], - version = 1, - exportSchema = false + autoMigrations = [ + AutoMigration(from = 1, to = 2) + ] ) @TypeConverters( PriceTypeConverter::class, diff --git a/app/src/main/java/dev/shorthouse/coinwatch/di/RoomModule.kt b/app/src/main/java/dev/shorthouse/coinwatch/di/RoomModule.kt index 550376d7..5ac99ee0 100644 --- a/app/src/main/java/dev/shorthouse/coinwatch/di/RoomModule.kt +++ b/app/src/main/java/dev/shorthouse/coinwatch/di/RoomModule.kt @@ -36,6 +36,8 @@ object RoomModule { context.applicationContext, CoinDatabase::class.java, Constants.COIN_DATABASE_NAME - ).build() + ) + .fallbackToDestructiveMigration() + .build() } }