Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change the deletion rule of a core data relationship and still perform a lightweight migration?

I have two apps which talk to the same API. As they've grown, they've each taken on more of the API's features, and I'm now at the stage where they're identical except for the arrangement of the starting controllers.

Their core data models have so far been maintained separately, containing only those entities which they needed; but I'd now like to use the same data model versions for each one. However, their latest versions do differ in some small ways, especially in the deletion rules of some of the relationships.

If I change a deletion rule from Nullify to Cascade or vice versa between versions, will I still be able to perform a lightweight migration? It's not mentioned in Apple's web page, though it does list similar steps as being compatible (e.g. to-one <-> to-many)

like image 521
Simon Avatar asked Dec 10 '22 23:12

Simon


1 Answers

Yes. In fact if changing the delete rule were the only change, you wouldn't even need to do migration.

Some explanation of that: Migration is only necessary if the version hash changes. The version hash only considers details that affect how data is saved in the persistent store. If you look up versionHash on NSRelationshipDescription, the only things it adds are "...the name of the destination entity and the inverse relationship, and the min and max count." Delete rules don't matter to the version hash, so they don't matter to migration.

like image 171
Tom Harrington Avatar answered Jan 23 '23 13:01

Tom Harrington