Realm migration inadequately documented. Can anyone clarify?

Viewed 579

Performing migrations on a Realm database is poorly documented and the documentation seems to be out-of-date. There are two areas explaining how to migrate data:

-- The simple example on the Realm website: https://realm.io/docs/swift/latest/

-- A more detailed example in the Github examples section: https://github.com/realm/realm-cocoa/blob/master/examples/ios/swift-3.0/Migration/AppDelegate.swift

Neither of these examples adequately explain how to migrate data between schema versions. I've tried playing around with the examples and have yet to get any migrations working. As well, I've had problems with app crashes when upgrading to newer Realm versions without schema changes and data changes, which don't occur in the Simulator but occur when installing the app from TestFlight or the App Store.

Seems like the Realm documentation and examples detailing migrations are due for a refresh. My areas of interest are:

  1. Upgrading to a newer Realm version without a schema change in the database. Unclear whether I should continue using the default.realm file generated with a previous version, or whether I need to re-generate the default.realm file using the newer Realm framework version.

  2. Adding a new attribute to a Realm object.

  3. New objects ("rows") added to an existing class without any schema change.

  4. No schema changes to existing classes in the database, but addition of an entirely new class or classes.

  5. Any combination of the above.

Thanks!

2 Answers
Related