From bd12c89a3c8578c5e2e59b07d42dc8cafd4f42da Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 31 Aug 2020 16:29:34 +0200 Subject: [PATCH] Move the DB version number to the Migration class, I think it has more sense. Also increase the value. --- .../internal/database/RealmSessionStoreMigration.kt | 4 ++++ .../database/SessionRealmConfigurationFactory.kt | 10 +++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt index e410e4cfa6..ca309cc444 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt @@ -27,6 +27,10 @@ import javax.inject.Inject class RealmSessionStoreMigration @Inject constructor() : RealmMigration { + companion object { + const val SESSION_STORE_SCHEMA_VERSION = 4L + } + override fun migrate(realm: DynamicRealm, oldVersion: Long, newVersion: Long) { Timber.v("Migrating Realm Session from $oldVersion to $newVersion") diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/SessionRealmConfigurationFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/SessionRealmConfigurationFactory.kt index 456eecc54a..8dde1e9579 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/SessionRealmConfigurationFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/SessionRealmConfigurationFactory.kt @@ -19,13 +19,13 @@ package org.matrix.android.sdk.internal.database import android.content.Context import androidx.core.content.edit +import io.realm.Realm +import io.realm.RealmConfiguration import org.matrix.android.sdk.internal.database.model.SessionRealmModule import org.matrix.android.sdk.internal.di.SessionFilesDirectory import org.matrix.android.sdk.internal.di.SessionId import org.matrix.android.sdk.internal.di.UserMd5 import org.matrix.android.sdk.internal.session.SessionModule -import io.realm.Realm -import io.realm.RealmConfiguration import timber.log.Timber import java.io.File import javax.inject.Inject @@ -46,10 +46,6 @@ internal class SessionRealmConfigurationFactory @Inject constructor( val migration: RealmSessionStoreMigration, context: Context) { - companion object { - const val SESSION_STORE_SCHEMA_VERSION = 3L - } - // Keep legacy preferences name for compatibility reason private val sharedPreferences = context.getSharedPreferences("im.vector.matrix.android.realm", Context.MODE_PRIVATE) @@ -74,7 +70,7 @@ internal class SessionRealmConfigurationFactory @Inject constructor( realmKeysUtils.configureEncryption(this, SessionModule.getKeyAlias(userMd5)) } .modules(SessionRealmModule()) - .schemaVersion(SESSION_STORE_SCHEMA_VERSION) + .schemaVersion(RealmSessionStoreMigration.SESSION_STORE_SCHEMA_VERSION) .migration(migration) .build()