Reputation: 10378
I'm pretty new to doing data migrations with Core Data, but I've got everything almost set up and it doesn't seem to be too hard.
When the user opens the updated app for the first time, the database should be upgraded as expected during the app loading. I'm guessing the update won't take more than a few seconds at most, so I won't even let the user know this is happening.
What happens if the user decides to quit the app in the first few seconds while the database is upgrading?
Is this handled nicely? i.e. - does the update continue to finish while the app is shutdown? Or, is the intermediate state of the upgrade saved, and continued flawlessly from where it left off the next time the app is started?
Do I have to worry about this at all (with a large amount of users, I'm sure at least a few users will quit during updating). Or, has Apple taken care of all of this - am I needlessly worrying about it?
Upvotes: 1
Views: 155
Reputation: 4610
Core Data Lightweight Migrations will succeed or fail. When the migration is not committed until the end of the migration process. If the user quits the app at just the right time they would re migrate on relaunch of the app because the transaction did not complete properly.
If the user backgrounds the app and then resumes the execution state of the lightweight migration resumes as well ensuring data integrity.
Information on Core Data Migrations https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmMigrationProcess.html
Upvotes: 2