Reputation: 7479
I have successfully done Core Data lightweight model migrations before in my app, but currently I'm struggling to deal with an issue where the migration seems to run as soon as the app is updated and run, even before UIApplication's willFinishLaunchingWithOptions
method is called, let alone setting up the Core Data stack. One of my goals in this migration is to fix some bug with a Transformable property, so it's vital that I load up the app's persistent store with the old model initially so I can fix some things before running the lightweight migration. But in my testing, it seems that the SQLite store file is changed to the new model as soon as the updated app is installed and run, which signifies that the lightweight migration has already run before the updated app is up and running.
Some details:
NSPersistentContainer
but add the NSPersistentStoreCoordinator
and load the NSPersistentStore
manually, using addPersistentStoreWithType:configuration:URL:options:error
willFinishLaunchingWithOptions
, I notice that the sqlite store file has already updated to the new model, before any NSPersistentStoreCoordinator
is created or a NSPersistentStore
is addedNSPersistentContainer
) and ran a similar test there (running the app with original model, then updating the model and running it again), and in this case, it works as expected ... the Sqlite store file still shows the old model until the NSPersistentContainer
is loadedWhat's the best explanation for this issue, and/or the best way to debug something like this? I'm a bit stumped, and don't know where to look.
Upvotes: 0
Views: 33