With the progress of an app, the realm migration is increased by a large volume. Is there any optimal design pattern which can significantly reduce the coding for migration? Suppose, I have the following migration:
if (!schema.contains(Subject.class.getSimpleName())) {
RealmObjectSchema inputConfigSchema = schema.create(Subject.class.getSimpleName())
.addField("name", String.class)
.addField("difficulty", String.class);
if (!schema.get(Student.class.getSimpleName()).hasField("subject")) {
schema.get(Student.class.getSimpleName()).addRealmObjectField("subject", inputConfigSchema);
}
}
if (!schema.get(Student.class.getSimpleName()).hasField("age")) {
schema.get(Student.class.getSimpleName()).addField("age", Integer.class);
schema.get(Student.class.getSimpleName()).setNullable("age", false);
}
}
please suggest a suitable design pattern to optimize this type of realm migration
Aucun commentaire:
Enregistrer un commentaire