What is the right way to deal with data model changes?

I already have an app in the app store. I want to do an update. My local datastore has changed with an extra table and several fields added to an existing table. I want to save data in old tables. How should I do it? Can someone point me to textbooks that handle such changes?

+3
source share
2 answers

Check the Apple docs for moving the primary data instance. They make it very easy for 90% of cases. The main idea is that you break xdatamodel into versions, so it has a migration path

Here is a tutorial that can help you with Core Data Migration

+2
source

Assuming you are using SQLite: use a new database with a different name for your update. At startup, check the table with the old name, copy the necessary data and delete it when you are done.

CoreData has its own update data, which may or may not work for you. You should see how to change the data model.

+3
source

All Articles