Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>Changing one property will cause a migration</li> <li>Renaming a property will be "guessed" at via lightweight migration as a deleted property and then an added property; effectively deleting the values in the property.</li> </ol> <p>I would not recommend a heavy migration ever; it is just too expensive. It is frequently faster to just export to another format and then read it back in.</p> <p>I would consider not renaming the property but just <em>adding</em> the new property and then in the <code>-awakeFromFetch</code> move the data from the old property to the new one. </p> <p>Or don't rename the property, what is the code reason for the rename?</p> <h2>Update 1</h2> <p>Yes, you can make a decision on migration. To do that, you ask the store if it needs to be migrated. By calling <code>-[NSManagedObjectModel isConfiguration:compatibleWithStoreMetadata:]</code> you can determine if a migration is needed. From there you can then determine the file size and make your decision.</p> <p>However, I would not do a custom migration. There are other options:</p> <p>If you really need to rename the property, consider this:</p> <ol> <li>Check for a migration situation</li> <li>Migration to an intermediate version where the new property name is <em>added</em>.</li> <li>Walk your data and copy the values from the old property to the new</li> <li>Migrate to the final model where the old property is removed.</li> </ol> <p>I am willing to bet that this will be faster than a custom migration and it will consume far less memory since only one copy of the data is resident. </p> <p>I <strong>really</strong> don't like heavy weight migrations on iOS :)</p> <h2>Update 2</h2> <p>Thanks to the comment by Alexei Kuznetsov; you can set the Renaming ID on the property you are going to rename to the original name of the property and lightweight migration should migrate the data correctly. Naturally I recommend testing this to make sure there are no surprises.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload