0

i have a sqlite file in my app. the app is with enterprise certificate .

Now , if i am going to create new version with the changes in database then :

1) i have to change my Sqlite file name ?
2) if yes , then is there any way that if any person who is using my app, who has his saved data in app , will be inserted automatically in new version of my app .

otherwise if i create new file and then the older data would be removed!!!

Thanks in advance..

3
  • You might find this question and its answers useful: stackoverflow.com/questions/554009/… Commented Mar 30, 2012 at 9:04
  • Best way is you should create structural changes in existing database only. It would be easy to do and more logical. Commented Mar 30, 2012 at 9:09
  • but if my app is in device and i am installing new version then how i can get new changes with take care that old data would remain there. Commented Mar 30, 2012 at 9:11

2 Answers 2

1

1) AFAIK, when you update, the old app bundle is replaced with the new app bundle. But the user data is untouched. i.e. the copy of the sqlite DB which the app changes with use by the user, is not deleted/replaced.

2) So, you can possibly ship changes to the DB as queries:

a) New tables go in as CREATE TABLE queries.

b) Changes to table structure go in as ALTER TABLE queries.

3) Now, one problem is, you didn't think about all this when you shipped the older version. So how will you make sure the queries 2a and 2b are executed only on upgrade?

a) When you first get control in the application, before allowing user interaction, fire a dummy SELECT SINGLE * FROM <tablename> on a table you have 'changed' in new version.

b) Use sqlite3_column_count and sqlite3_column_name to find out which version of the app the DB corresponds to [old or new].

c) If it is new version (i.e. new columns already exist), do nothing, else fire the queries I mentioned earlier as 2a and 2b.

Sign up to request clarification or add additional context in comments.

Comments

0

If you haven't started by using this, then it's probably moot, but Core Data handles migrations (IMHO) fairly well; enough that it's worth the hurdle of learning the API. We've had great success with it (including complex migrations, inserting new objects "between" relationships, etc).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.