public class Migration implements RealmMigration {
@Override
public void migrate(final DynamicRealm realm, long oldVersion, long newVersion) {
RealmSchema schema = realm.getSchema();
// Migrate from version 0 to version 1
if (oldVersion == 0) {
// Create a new class
schema.create("DisabledGroup")
.addField("groupId", String.class, FieldAttribute.REQUIRED)
.addField("isMsgBlocked", Boolean.class, FieldAttribute.REQUIRED);
oldVersion++;
}
}
}
io.realm.exceptions.RealmMigrationNeededException: Primary key not defined for field 'groupId' in existing Realm file. Add @PrimaryKey.