mentrena / SyncKit

Automatic CloudKit synchronization
https://mentrena.github.io/SyncKit/
MIT License
507 stars 59 forks source link

Question on schema changes #109

Closed Chivs closed 4 years ago

Chivs commented 4 years ago

If there needs to be a schema change, for example adding additional fields to an existing sync object, what is the correct approach to doing this, to ensure the iCloud schema is updated and shared objects sync correctly.

mentrena commented 4 years ago

If you're adding properties you probably want to ensure that records uploaded using the new schema (and containing the new property) are not downloaded by a version of the app running the old schema (where the objects wouldn't know of that property) You can do that by setting compatibilityVersion on the synchroniser object. This means that if a synchroniser with a certain version encounters CloudKit records with a higher version, the sync will fail with a higherModelVersionFound error. At that point you would prompt the user to update the app on that device, and once they do they should be able to synchronise that device again.