Search code examples
iosswiftcore-datacore-data-migration

Do we need to add new version to core data if we add new tables into it?


I have an existing core data project now I want to add some more tables into it so my question is do we need to add change current version of CoreData and add new version to it ? Also my app is already live. Now I want to publish another version of application by adding some more tables to it.


Solution

  • https://developer.apple.com/documentation/coredata/using_lightweight_migration

    Core Data Migration In order to follow core data migration we should keep on versioning our .xcdatamodeld file. Also to address new changes we should not make any changes in existing data model. Instead we should create a new version of .xcdatamodeld and perform changes there. We should follow core data migration if there are changes in:

    Entity - Add a entity, Remove a entity, Renaming a entity. Attribute- Add an attribute, Remove an attribute, Renaming an attribute, Relationship - Add a relationship , Remove an relationship , Renaming an relationship .