Search code examples
ioscore-data-migration

Do i need a core data migration when i add a new model to my .xcdatamodeld file


i have a an .xcdatamodeld which already has 2 entities, i have added another entity into this file(am not sure whether this is the right way to add a new entity), anyways my question is, do i need to implement any kind of migrations to take care of users who already have the app installed on their devices.

Please note, i have not modified any columns or schema on already existing entities.

cheers.


Solution

  • You don't need to do migration if you just only adding new entity, assuming that it doesn't have relationship with the other. According to raywenderlich.com, you have to do migration for the following scenario:

    1. Deleting entities, attributes or relationships.
    2. Renaming entities, attributes or relationships using the renamingIdentifier.
    3. Adding a new, optional attribute.
    4. Adding a new, required attribute with a default value.
    5. Changing an optional attribute to non-optional and specifying a default value.
    6. Changing a non-optional attribute to optional.
    7. Changing the entity hierarchy.
    8. Adding a new parent entity and moving attributes up or down the hierarchy.
    9. Changing a relationship from to-one to to-many.
    10. Changing a relationship from non-ordered to-many to ordered to-many (and vice versa).