From 2a4919491ad226199f797264ad65875a4d964046 Mon Sep 17 00:00:00 2001 From: A117870935 Date: Mon, 28 Aug 2023 19:37:38 +0530 Subject: [PATCH] Fix local db version to avoid crash during app upgrade. --- .../nextcloud/client/database/NextcloudDatabase.kt | 5 ++++- app/src/test/java/com/nmc/DatabaseVersionTest.kt | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 app/src/test/java/com/nmc/DatabaseVersionTest.kt diff --git a/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt b/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt index db98e777db33..9f3fd961ea4b 100644 --- a/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt +++ b/app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt @@ -70,7 +70,10 @@ abstract class NextcloudDatabase : RoomDatabase() { abstract fun fileDao(): FileDao companion object { - const val FIRST_ROOM_DB_VERSION = 65 + //NMC customization + //NMC play store version 7.21.9 had db version 64 before SqLite to Room migration + //Keeping it 65(as per NC) will lead to crash when user tried to upgrade the app + const val FIRST_ROOM_DB_VERSION = 64 private var INSTANCE: NextcloudDatabase? = null @JvmStatic diff --git a/app/src/test/java/com/nmc/DatabaseVersionTest.kt b/app/src/test/java/com/nmc/DatabaseVersionTest.kt new file mode 100644 index 000000000000..128277906484 --- /dev/null +++ b/app/src/test/java/com/nmc/DatabaseVersionTest.kt @@ -0,0 +1,14 @@ +package com.nmc + +import com.nextcloud.client.database.NextcloudDatabase +import org.junit.Test + +class DatabaseVersionTest { + + @Test + fun validateDatabaseVersion() { + //for NMC the version will start from 64 only + //validating via test case to check if any test changes done during rebasing or merging + assert(64 == NextcloudDatabase.FIRST_ROOM_DB_VERSION) + } +} \ No newline at end of file