Frage

So, I have the rather popular problem of updating the SQL data in my core data powered app upon the release of a new version of the app.

Quick summary of the app's mechanics

I have a console app that uses the same xcdatamodeld file as my app, in which I pre-fill the SQL database (sqlite file). I then use this file in my app for the sake of prefilled data.

The Problem is, every time I run such an update(usually monthly), the documents folder is preserved and the app ignores the new data and displays blank pages where the new data should be. This is obviously solved by deleting & reinstalling the app but that's too much of a hassle for my users who would need new content monthly.

What I've tried so far

-I was advised to look through the core data migration docs and utilise "data model versioning". This didn't work for me because my issue is with the actual data not the model. The model remains the same, it's just the data it feeds off that changes.

  • I tried loading a JSON file from a web-service on a daily basis to avoid the need to ever update the app itself, but I got complaints from my clients, stating that one of the main features the users wanted was offline access. Especially for those in countries where mobile internet access is rather expensive and unreliable.

-The above reason ruled out other solutions such as stackmob etc.

After reading and much thinking, I feel this might work;

Write code to check for an existing database during app launch. If the existing DB is different from the new one(I plan to use some sort of numeric dependent condition e.g if version no1 < new version), then it will delete the existing DB and use the new DB from the update. Without requiring the user to delete and reinstall the app every time an update is released.

At this stage, I am open to any other ideas that will allow me pre-populate the database and update it monthly without any worries. (I don't mind re-writing the app from scratch).

Any help is welcome. [Dont let my mastery of markdown fool you, I'm a beginner ;) ]

War es hilfreich?

Lösung

You could just change the sqlite filename each time you update your application.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top