Search code examples
macoscocoacore-datacore-data-migration

Will the core data migration mechanism deal with new data on a pre populated entity?


I have a Mac application that uses core data with basically one entity.

This app creates particles for Quartz and comes with a variety of particle setups ready to use, something like fire, smoke, comet, etc. These particles are saved on that entity and shipped to the user, or in other words, the application comes with a pre populated entity.

This same entity is used to save the particles created by the user (I have a flag that I set to know if the particles were created by the user or by me).

I would like to update this app by including more pre populated particles.

The problem is that every user has already saved their particles. I need the new version not to mess with that and add the new particles I will create to them.

I know that core data mechanism is more suited to migrate structures but what about data? I suspect core data will not do that, so I will have to check the database to see if the new particles are there and add them by code the first time the user runs the app, right? or is there a way to do that automatically?


Solution

  • Short answer is no. Migrations are for structural changes only. It will not add new data.

    The creation of new data or the updating of old data iOS a business decision and is outside of the scope of the migration API.