From ec6bdb0ab88ac3ba963614cfc15a192d807e4ef7 Mon Sep 17 00:00:00 2001 From: kirbylife Date: Wed, 20 Mar 2024 00:24:27 -0600 Subject: [PATCH] Fix the Database versions issue --- qml/js/WallaBase.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/qml/js/WallaBase.js b/qml/js/WallaBase.js index 19d2100..a07ef0f 100644 --- a/qml/js/WallaBase.js +++ b/qml/js/WallaBase.js @@ -857,8 +857,7 @@ function createLatestDatabase( db ) "password TEXT NOT NULL, " + "clientId TEXT NOT NULL, " + "clientSecret TEXT NOT NULL, " + - "lastSync INTEGER DEFAULT 0," + - "fetchUnread INTEGER DEFAULT 0" + + "lastSync INTEGER DEFAULT 0" + ")" ); @@ -936,14 +935,24 @@ function _updateSchema_v3( db ) ); } +var errorFlag = false; function _updateSchema_v4( db ) { db.transaction( - function( tx ) { - tx.executeSql( "ALTER TABLE servers ADD COLUMN fetchUnread INTEGER DEFAULT 0" ); - tx.executeSql( "UPDATE servers SET fetchUnread=0" ); + function ( tx ) { + try { + tx.executeSql( "ALTER TABLE servers ADD COLUMN fetchUnread INTEGER DEFAULT 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" ); } ); } +