Migration and iCloud

If you are using iCloud, you can only migrate the contents of a store using automatic lightweight migration. To migrate a persistent store that is in iCloud, you add the store to a persistent store coordinator using addPersistentStoreWithType:configuration:URL:options:error: and pass at least the following options in the options dictionary:

NSDictionary *optionsDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
    [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
    [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
    <#Ubiquitous content name#>, NSPersistentStoreUbiquitousContentNameKey, nil];

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. Any changes from stores using the new version are also merged in. Existing changes can not, however, be migrated to a new model version if the migration is performed using a custom mapping model.