Fix the Database versions issue

pull/2/head
kirbylife 2024-03-20 00:24:27 -06:00
parent 33f87cf061
commit ec6bdb0ab8
1 changed files with 14 additions and 5 deletions

View File

@ -857,8 +857,7 @@ function createLatestDatabase( db )
"password TEXT NOT NULL, " + "password TEXT NOT NULL, " +
"clientId TEXT NOT NULL, " + "clientId TEXT NOT NULL, " +
"clientSecret TEXT NOT NULL, " + "clientSecret TEXT NOT NULL, " +
"lastSync INTEGER DEFAULT 0," + "lastSync INTEGER DEFAULT 0" +
"fetchUnread INTEGER DEFAULT 0" +
")" ")"
); );
@ -936,14 +935,24 @@ function _updateSchema_v3( db )
); );
} }
var errorFlag = false;
function _updateSchema_v4( db ) function _updateSchema_v4( db )
{ {
db.transaction( db.transaction(
function ( tx ) { function ( tx ) {
try {
tx.executeSql( "ALTER TABLE servers ADD COLUMN fetchUnread INTEGER DEFAULT 0" ); tx.executeSql( "ALTER TABLE servers ADD COLUMN fetchUnread INTEGER DEFAULT 0" );
tx.executeSql( "UPDATE servers SET fetchUnread=0" ); tx.executeSql( "UPDATE servers SET fetchUnread=0" );
} catch ( e ) {
if ( errorFlag ) throw e;
errorFlag = true;
resetDatabase();
_updateSchema_v4( db );
}
db.changeVersion( db.version, "0.4" ); db.changeVersion( db.version, "0.4" );
} }
); );
} }