Search code examples
ioscore-datacore-data-migration

Lightweight Migration Necessary?


I have an existing app. I already performed a lightweight migration once, so I'm not totally unfamiliar. However, I recently was working on my app and, without thinking, added two new entities without adding a new Core Data model version.

However, when I uploaded the app via Xcode onto my phone and several test users phones, it didn't cause problems.

Is it possible that I don't need to do a lightweight migration?


Solution

  • When you set up your app for a lightweight migration, you probably inserted the following lines into your CoreData framework. These settings enabled the options that support lightweight migrations (these are from a Swift 3.0 app so they may vary a bit):

    NSMigratePersistentStoresAutomaticallyOption as NSObject: true,                 
    NSInferMappingModelAutomaticallyOption as NSObject: true 
    

    If you've left these lines in place, then CoreData will continue to perform lightweight migrations correctly when they're required so you should be OK as long as you don't do anything that requires more action on your part - like changing the name of an entity or property.