database version number
Hey, If I ship new database within the app, how can I increment it's version so if it already exists, current get deleted and new comes in?
We are also facing the same concern.
The easiest way to do this; would be to open the existing database; get its version number; check to see if it is older; then if it is older; close the db; copy the new db over...
do you have any sample for incremental updates implementation?
Thanks Nathan. Should have realized that without asking.
Anyone seeking this do it like this:
After instantiating new database connection like documentation says: new sqliteModule(databaseName, function (err, dbConnection) {.... /* Check current version / database.version(function (error, version) { if (version < CONSTANTNEWVERSIONNUMBER) { / Delete old database */ sqliteModule.deleteDatabase(databaseName); if (!sqliteModule.exists(databaseName)) { sqliteModule.copyDatabase(databaseName); this.afterDBUpdate (); // to handle version incrementation and new connection. } ...
SqliteViewModel.prototype.afterDBUpdate = function () { new sqliteModule(databaseName, function (err, dbConnection) { database = dbConnection; database.version(CONSTANTNEWVERSIONNUMBER); // Sets new version number }); };