From 3e8f0af5837bdc867f26e34c91c8678d552f558d Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 21 Jun 2020 03:08:03 -0400 Subject: [PATCH] Schema upgrade debugging Include flags in repo update checks indicating whether a database table that was previously supposed to be removed was removed and whether a new table was created. This should help us figure out whether we can safely perform schema update steps or whether we need to figure out why some schema update steps aren't being applied. --- chrome/content/zotero/xpcom/schema.js | 16 ++++++++++++++++ resource/schema/userdata.sql | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index b4877e3421..baeab1a0b9 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -1514,6 +1514,18 @@ Zotero.Schema = new function(){ url += '&m=' + mode; } + // TEMP: DB diagnostics + let exists = yield Zotero.DB.tableExists('transactionSets'); + url += "&ts=" + (exists ? "1" : "0"); + if (exists) { + Zotero.logError("DB table 'transactionSets' still exists"); + } + exists = yield Zotero.DB.tableExists('dbDebug1'); + url += "&db1=" + (exists ? "1" : "0"); + if (!exists) { + Zotero.logError("DB table 'dbDebug1' does not exist"); + } + // Send list of installed styles var styles = Zotero.Styles.getAll(); var styleTimestamps = []; @@ -3025,6 +3037,10 @@ Zotero.Schema = new function(){ yield Zotero.DB.queryAsync(`DELETE FROM itemRelations WHERE predicateID=(SELECT predicateID FROM relationPredicates WHERE predicate='owl:sameAs') AND object LIKE ?`, 'http://zotero.org/users/local/%'); } + else if (i == 109) { + yield Zotero.DB.queryAsync("CREATE TABLE dbDebug1 (\n a INTEGER PRIMARY KEY\n)"); + } + // If breaking compatibility or doing anything dangerous, clear minorUpdateFrom } diff --git a/resource/schema/userdata.sql b/resource/schema/userdata.sql index 42ba4f2ee4..6068fc3e45 100644 --- a/resource/schema/userdata.sql +++ b/resource/schema/userdata.sql @@ -1,4 +1,4 @@ --- 108 +-- 109 -- Copyright (c) 2009 Center for History and New Media -- George Mason University, Fairfax, Virginia, USA @@ -456,4 +456,8 @@ CREATE TABLE translatorCache ( fileName TEXT PRIMARY KEY, metadataJSON TEXT, lastModifiedTime INT -); \ No newline at end of file +); + +CREATE TABLE dbDebug1 ( + a INTEGER PRIMARY KEY +);