Search code examples
iphonecore-datacore-data-migration

Adding data after lightweight migration process


I am not sure if it can be done by using lightweight migration. My problem is relatively simple, but I could not find a solution anywhere on the net.

I have a database where I need to add a new version by adding one entity. The LW migration works like a charm. Then I want to add some data to the updated database immediately.

Is there a solution to detect if a migration has occured (event after the migration itself, but obviously once only). Then I want add some data (migrate normal application settings info to the database).

Thank you.


Solution

  • After the LW migration with addPersistentStoreWithType:configuration:URL:options:error: You can use NSManagedObjectModel's isConfiguration:compatibleWithStoreMetadata: to check whether the schema of the - possibly migrated - store is compatible with the coordinator’s model.