ICloud, master data, migration and model matching

As the Apple documentation says

Schema migration using matching models is not supported (easy migration is supported).

I was interested to learn about the options that we have if we need to deal with fonctionnality and the display of the iCloud model ... I know that I will need to change my Core Data model in the future in order to add functionality to my application (and not only in an easy way). The fact is that I can’t say what new entities will be needed and what relationships with previous model objects will be established.

I thought of this sequence:

1 - Launching an application migrating the mapping of my underlying data model

2 - Allows you to sync it with iCloud

This will work if iCloud contains transaction log files adapted to the new model. In the case of old transaction log files (tools adapted to the old model), it will not be executed.

To avoid this, I thought about this:

1 - Launching my application that allows me to sync it with iCloud

2 - Performing a display migration of my underlying data model

3 - Delete old iCloud data updating it with a new

This will not work if iCloud already contains updated transaction log files (tools adapted to the new model).

I need a way to check if transaction logs in iCloud are compatible with my current kernel data model. Is there any way to do this?

Thanks.

+4
source share
1 answer

I would not recommend using Core Data with iCloud in a production application.

Not stable enough. There is no easy way to check if the en / disabled application is enabled in iCloud settings. And not to mention the problems that may arise if the user disables iCloud support after its inclusion.

Migration is another problem. Easy migration works quite well. But in order to make the migration of the matching model, you need to clear / display the contents of the existing iCloud "virtual folder", create a new one (with a new name) and change the value associated with NSPersistentStoreUbiquitousContentURLKey. And you need to make sure that all customers do the same. Its complicated but doable. Not sure if it's worth it ...

Regarding the version compatibility issue, I have not tried it yet, but the idea would be to somehow get the repository metadata from the iCloud transaction log and use the "compatibleWithStoreMetadata" method in ManagedObjectModel to check if the version matches:

// Get current model NSManagedObjectModel *myModel = [self managedObjectModel]; // Check compatibility BOOL isCompatible = [myModel isConfiguration:nil compatibleWithStoreMetadata: metadataFromTransactionLogEntry]; 
+2
source

All Articles