From b72ca80a195b7e87513df63de6ff3ef334975b46 Mon Sep 17 00:00:00 2001 From: Harry S Date: Sat, 11 Nov 2023 13:33:18 +0000 Subject: [PATCH 1/3] Add fallbacktodestructivemigration to room database setup --- app/src/main/java/dev/shorthouse/coinwatch/di/RoomModule.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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() } } From 12a0b4ea20f16f8f12fa687a6f0de400391ed73e Mon Sep 17 00:00:00 2001 From: Harry S Date: Sat, 11 Nov 2023 13:33:35 +0000 Subject: [PATCH 2/3] Create room migration from v1 to v2 --- .../shorthouse/coinwatch/data/source/local/CoinDatabase.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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, From a13c3469047bb48dd0999bcc7cf53e3fdce5f6d0 Mon Sep 17 00:00:00 2001 From: Harry S Date: Sat, 11 Nov 2023 13:33:52 +0000 Subject: [PATCH 3/3] Add enum proguard rule --- app/proguard-rules.pro | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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.**{ + *; +}