ios - Adding some but not all data from new app version’s database to existing database -


I am creating a core data app with previously loaded data using a SQL file. I am able to create preloaded data, insert the SQL file into that project, and there is no problem. When the user first opens the app for the first time, the pre-populated store is copied to the default store.

However, I am thinking that in future versions I will continue to add to this database. I want users to download the existing version with the latest DB without first removing user-generated data or user-edits for data in previously-loaded DB.

This is not a migration problem because the model is not changed. Basically, when a new version of the app is opened for the first time, then I want to check it out in the pre-populated store of the new object and want to add them to the user's store. Any suggestions are welcome

For each object that your preloaded data is, Include in the file where it was added to the first preload of the file. Then

  1. Add new data by looking at the previous app version in the user's default. Compare its current version if they are similar, then stop, otherwise continue in the next step. (If there is no previous version number, continue on to the next step).
  2. Obtain all objects that were recently added to version number saved from step 1.
  3. Add those items to the user's constant store.
  4. Update the app version in the user's version so that it is next running.

You can check this every time you launch the app. You would like to save a numerical version number in the user default which will always increase in future versions of the app.

The easiest way to record version information in the preload file is to add just one additional field to create a new existence like the VersionWhereAdded on each unit type The method will contain a number of links from a version number and the objects included in that version.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -