I have simple WebSQL database with 1 table and 3 columns. I would like to add one more column, but I can't do it if the database already exist. It's only possible after I have cleaned it in the cache, but then I'm loosing all the data.
How can I add new column to a table without removing the database?
// database creating
MYDB.init.open = function(){
MYDB.init.db = openDatabase("MYDB","1.0"," super-data-base",1024*1024*5);
}
//table creating
MYDB.init.createTable = function(){
var database = MYDB.init.db;
database.transaction(function(tx){
tx.executeSql("CREATE TABLE IF NOT EXISTS mytable (ID INTEGER PRIMARY KEY ASC,item TEXT,description TEXT)", []);
});
}
//
//a lot of code for adding datas and reading datas
//
//database updating that does not work
MYDB.init.updateTable = function(){
var database = MYDB.init.db;
database.transaction(function(tx){
tx.executeSql("ALTER TABLE mytable ADD time VARCHAR NOT NULL BEFORE description");
});
}
All other UPDATE functions are working well.