CoreData iCloud Migration “looses” data when more

2019-07-07 10:28发布

问题:

i recently had some major problems with an update of my app. Numerous users complained about dataloss after they migrated to the newest version.

After many hours i am still not sure what happened but i have a theory that i would like to confirm.

in the documentation Apple says:

Migration and iCloud

Changes to a store are recorded and preserved independently for each model version that is associated with a given NSPersistentStoreUbiquitousContentNameKey. A persistent store configured with a given NSPersistentStoreUbiquitousContentNameKey only syncs data with a store on another device data if the model versions match.

If you migrate a persistent store configured with a NSPersistentStoreUbiquitousContentNameKey option to a new model version, the store’s history of changes originating from the current device will also be migrated and then merged with any other devices configured with that new model version

does that mean that when i have more than one device and migrate the first. All data NOT originating from that device gets "lost" because the model versions do no longer match until the other device also updates to the newest version and its data and change history get migrated to the new model version.

Because that seems to be one scenery where i can replicate the problem. Is that really the case? any help and insights are appreciated...

回答1:

That's approximately correct. If two devices are using different versions of the data model, they can't sync with each other. Data is not "lost" in this situation, but syncing stops. Once all devices are upgraded, syncing should resume.

I don't know if that's what's happening in your case, but that's what those docs are trying to tell you.