Skip to content

Commit

Permalink
Fixed Realm migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Str4tocaster committed Apr 23, 2018
1 parent 2d674fa commit dec5f7e
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class RealmManager {
private static final String REALM_DATABASE_NAME = "realm_database.realm";
private static final int REALM_DATABASE_VERSION = 13;
private static final int REALM_DATABASE_VERSION = 14;
private static final String LOG_TAG = RealmManager.class.getSimpleName();
private final RealmConfiguration realmConfiguration;

Expand Down Expand Up @@ -200,6 +200,19 @@ public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {

oldVersion++;
}

// Try to fix Realm migration issue
if (oldVersion < 13) oldVersion = 13;

if (oldVersion == 13) {
RealmObjectSchema chatDataSchema =
schema.get(ChatDataRealm.class.getSimpleName());

if (!chatDataSchema.hasField("lastPosition"))
chatDataSchema.addField("lastPosition", int.class);

oldVersion++;
}
}
})
.modules(new RealmDatabaseModule())
Expand Down

0 comments on commit dec5f7e

Please sign in to comment.