I have a mysqllite database in my app. After my app was approved by the appstore I submitted an update to the appstore. This update have been approved by Apple butI've a weird bug when the user update his app :
The database (for convenience reasons I didn't change its name) is not updated for the user who already had a previous version of the app.
For new users who buy the latest version, the database is ok.
That's a very annoying problem and I cannot find anything in the documentation regarding this kind of issue.
Any help welcome
The iPhone caches the database so you have to give it a different name if you want your update to use a new database. I normally handle this with a version number in the name, like this:
// Set up the database var dbVersion = 1.5; var db = Titanium.Database.install('mydatabase.db', 'mydatabase' + dbVersion);
Then I just change dbVersion whenever there's a change to the structure of the database.
Of course, because this would cause the installed database to be brand new, any user data would be lost.
If you are changing your database, but you want to retain any user data, you may have to retain the old name and add some code to alter the database. It's a shame that sqlite doesn't support the ALTER TABLE statement, so modifying a table's structure in code is complicated but not impossible.
Are you updating your database with install DB?
I remember reading install bug somewhere about renaming it, otherwise it would only execute once?
var db = Titanium.Database.install('mydatabase.db','name'); var db = Titanium.Database.install('mydatabase.db','newname');