/* the version is used only if the callbackfunction is not passed. In this case we pass it and therefore we have to create it with changeversion */
var db = openDatabase('documents', '1.0', 'Offline document storage', 5*1024*1024,
function (db) {//Enter only the creation of the database, the first time
db.changeVersion('', '1.0', function (t) {
t.executeSql('CREATE TABLE docids (id, name)');
}, error);
}
);
/*To make changes to the database, it will be necessary to slowly add the functions thus written*/
if(db.version == "1.0") {
db.changeVersion("1.0", "1.2",
function(trans) {
//All functions from 1.0 to 1.2
trans.executeSql('CREATE TABLE IF NOT EXISTS DEMO1 (id unique, data, foo)');
trans.executeSql('CREATE TABLE IF NOT EXISTS DEMO2 (id unique, data, foo)');
trans.executeSql('CREATE TABLE IF NOT EXISTS DEMO3 (id unique, data, foo)');
});
}
else if(db.version == "1.1") {
db.changeVersion("1.1", "1.2",
function(trans) {
//Only functions from 1.1 to 1.2
trans.executeSql('CREATE TABLE IF NOT EXISTS DEMO2 (id unique, data, foo)');
trans.executeSql('CREATE TABLE IF NOT EXISTS DEMO3 (id unique, data, foo)');
});
}