Core Data Migration error when migrating between non-consecutive versions

前端 未结 1 460
伪装坚强ぢ
伪装坚强ぢ 2021-02-09 18:14

The Problem

  • I\'ve got 13 versions of my core data model.
  • I\'ve made 13 mapping models (V1-V2, V2-V3 etc)
  • I\'ve got automatic migration switched
相关标签:
1条回答
  • 2021-02-09 18:54

    See this Stack Overflow question: Core Data Migration Across Multiple Version Upgrades

    Basically, the gist is that you don't need to create the complete set of mapping models. You just need mapping models between each pair of successive models, and then you can progressively migrate any old model through the intermediate models to the newest model.

    The performance may not be good depending on your store, because you're not doing the migration in one single step. It may be good enough, though, and may be worth it to not have to create the complete set of mapping models. You can also test out the performance of this method to determine whether you need to create maps between non-successive versions of your model.

    Marcus Zarra (Core Data aficionado extraordinaire) has the code here: http://media.pragprog.com/titles/mzcd/code/ProgressiveMigration/AppDelegate.m

    (I was just about to ask this question, but thanks to LazyTwitter I was pointed to this answer by Aaron Tuller: https://twitter.com/tullera/status/57708304683642880 )

    0 讨论(0)
提交回复
热议问题