database structure to update efficiently

You must Login before you can answer or comment on any questions.

hi folks,

imaging the follow scenario: i have a sqlite-database for an iphone app with some "documents" as templates. the user is able to add his own templates too. now i want to update the program and the database. is there any chance to do so without overwriting the users data? i thought about two different db but since this is an overhead it want to avoid this.

— asked 3 years ago by dev 1605
0 Comments

2 Answers

Accepted Answer

I was thinking this same thought.  Does Titanium let you delete files from your apps directory?  If so, I would think the code would flow like this.
 
if (old_database_exists)
insert into new_database (select * from old_database)
delete old database

— answered 3 years ago by Josh Lewis
answer permalink
1 Comment
  • so i will insert a flag in the database table which is true if it is userContent. so the statement's like:

    if (old_database_exists) insert into new_database (select * from old_database where flag=1) delete old_database

    — commented 3 years ago by dev 1605

When you're updating a production database, just like any other database app, you'll need to write SQL scripts to migrate your database to the newer version. Titanium doesn't provide any mechanism for doing this, but the practice of migrating production databases via SQL scripts is pretty common. You might consider adding database version information to your database and check that in your script, similar to how Ruby on Rails migrations work.

Your Answer

Think you can help? Login to answer this question!