Search code examples
ioscore-datansmanagedobjectcontextcore-data-migrationxcdatamodel

Transitioning old Datamodel to completely new one (start from scratch and delete everything else)


I have one xcdatamodel in the project, with 12 versions and I want to refactoring the model. Like create new one from scratch.

The new model will be very different and I don't want to keep the old entities, managedObjects, etc.... just empty everything, like start from new project, with a clean data model.

Also I have already apps in store so I need to be careful in the next update.

Questions:

  • As I don't want keep any data from old datamodel can I simply delete?

  • And how the app will bear after the next update (with this new model)? I can delete the old datamodel from app and point to the new one?

  • Or is better create new version of the current datamodel and just refactoring all entities and atributes?

With your experience how the best way?

Thanks a lot, I already search but I can't have the right answer for this specific case.


Solution

  • Answers:

    • Yes, you can simply delete the data store. (Check if it exists with NSFileManager.)
    • Yes, you can simply use another data model.
    • No, refactoring an old data model sounds like pain without any tangible benefits.

    As mentioned in the comment by Mike, the only concern is if this is really the desired behavior for your users.