vendredi 16 octobre 2015

Why does my sqlite database not get migrated when versioning Core Data model?

Every time I bump to a new version of my Core Data Model, the SQLite database doesn't get filled with the previous versions data.

For example:

  1. I have a users table.
  2. I click Editor > Add Model Version and change the model version to 7
  3. I add a field like "name" to the users table.
  4. In my app delegate, I'm using MagicalRecord to manage my database, and update the code to [MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:@"myapp 7"];
  5. I run the app in the simulator, and now whatever was in my users table, is completely gone.

However, if I move back to "myapp 6", the users are all there still.

Is there a way to bump the model version and keep the data from SQLite?

Thanks

Aucun commentaire:

Enregistrer un commentaire