Search code examples
migrationschemarealm

Realm Mobile Platform Schema change


I've been playing around with the Realm Mobile Platform and it works great. My question is how will migrations and schema changes work? If one client updates to the new schema but someone else doesn't will the older ones crash?


Solution

  • The easiest way to handle schema changes is to limit changes to just additive changes. By default Realm Mobile Platform can automatically sync an additive change (for example adding a property to an object model), such that older clients on a subset of the full schema can continue syncing with clients on the new full schema.

    On Cocoa right now in the beta, you need to up the schema version with an additive change, but the migration block is not necessary. For Android, you don't have to change the schema version and similar to Cocoa the migration block isn't necessary. We will align this going forward.

    If you have to perform a destructive schema change, such as removing a property from the object model, then you will have to create a new synchronized Realm with this schema, manually transfer the data subset to the new Realm, and leave the old Realm to support old clients.