Search code examples
ioscore-dataschemadatamodel

How to manage versions of Data Model Schema versions


I am having an app on app store. I have to update model version after every 2 months on average due to updates.

I have 7 versions right now and they will definitely increase in future.

enter image description here

I have some questions:

  • How I can efficiently manage this
  • Can I delete my older version?
  • How many versions I can add?

Solution

  • How I can efficiently manage this

    I recommend naming the model versions based on the release they are associated with. It helps to keep things straight.

    Can I delete my older version?

    Yes but not recommended. If someone is still using an older version of your app they will fail to migrate if the source is not there.

    How many versions I can add?

    Unlimited. However you should only have a version for each production release where data structure has changed. If you have intermediate versions that only exist for development, I would recommend removing them as they don't impact the user.

    Lastly, make sure you have a unit test that migrates from every old version to the current version. Core Data is not temporal and will not go from 1 to 2 to 3. It only understands source and destination. Can your app currently migrate from 1 to 10? If not, you need to address that.