CoreData migration without Model versioning OR reading sqlite wal file

159 views Asked by At

I have strange issue which is because that I forgot to change Core Data model version for an update of my application. Now I have an app on AppStore lets say version 1.0. And for version 1.1, I've changed the Core Data Model without creating 2nd version of it. I'm using Magical Records which deletes the previous Sqlite file in case of conflict. My app is on iOS 7 which uses Journal mode (Write ahead log, wal file) and I can't use my old sqlite file for data. For some reason I can't push an update 1.x in which I save all my data somewhere else and backup on 2.0, when conflict happens.

The issue is I don't want to loose my previous data. What to do ?

1

There are 1 answers

0
thom_ek On BEST ANSWER

There are two methods to solve this:

  1. Remove 1.1 from AppStore to avoid unecessary updates for existing users. Add missing model version (I hope You used SVN, GIT or any other source versioning tool?), theoretically you can manually revert all your changes to make model look same as 1.0 had, and then create version for 1.1. Submit new app version supporting migrations from 1.0.
  2. Remove 1.1 from AppStore as above. Manually migrate data from old SQLite store using FMDB or any other framework for direct sqlite access. Read all data via SQL and insert them in CoreData store using CoreData methods.