Have an app that has a half dozen models. We created a new app version with a new model that has an additional property on one entity.
The options for the persistent store:
do {
let options = [
NSMigratePersistentStoresAutomaticallyOption: NSNumber(value: true),
NSInferMappingModelAutomaticallyOption: NSNumber(value: true)
]
let _ = try persistentStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storeURL, options: options)
} catch {
try? FileManager.default.removeItem(at: storeURL) //Erase old sqlite
// Make new persistent store for future saves
let _ = try? persistentStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storeURL, options: nil)
}
Launch this with data from a previous version. A breakpoint in the catch block never triggers so the migration must have worked.
Since I'm in development, what happens if I run a different branch that doesn't have the new model? I assume the catch block is going to trigger—but it doesn't!
Why doesn't it trigger? Does Core Data essentially ignore the new entity property, so all is well?
I was just surprised ...