Scope: change the field name for migration

I would like to change the field name during the migration of the Realm domain. It seems that changing the field name is not supported, and only copy-and-remove is the only way to do it.

It is right? It consumes a lot of time.

The code below is my trial version to change the value field to summary copying and deleting.

 RealmSchema schema = realm.getSchema(); schema.get("Invoice") .transform(new RealmObjectSchema.Function() { @Override public void apply(DynamicRealmObject obj) { obj.set("summary", obj.getString("value")); } }) .removeField("value"); 
+6
source share
1 answer

You probably need a method: renameField

Example:

 RealmSchema schema = realm.getSchema(); schema.get("Invoice").renameField("value", "summary"); 
+6
source

All Articles