Fix no such column: IA.authorName error from early 6.0 beta upgrade

Fixes #3013
This commit is contained in:
Dan Stillman 2023-03-04 21:58:43 -05:00
parent 8ac77bf9f0
commit 1f45c44b86
2 changed files with 61 additions and 45 deletions

View file

@ -500,6 +500,10 @@ Zotero.Items = function() {
+ "FROM items JOIN itemAnnotations IA USING (itemID) "
+ "WHERE libraryID=?" + idSQL;
var params = [libraryID];
// TEMP: Fix faulty upgrade from early 6.0 beta
// https://github.com/zotero/zotero/issues/3013
try {
await Zotero.DB.queryAsync(
sql,
params,
@ -549,6 +553,15 @@ Zotero.Items = function() {
}.bind(this)
}
);
}
catch (e) {
if (e.message.includes('no such column: IA.authorName')
&& await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM version WHERE schema='userdata' AND version=120")) {
await Zotero.DB.queryAsync("UPDATE version SET version=119 WHERE schema='userdata'");
Zotero.crash();
}
throw e;
}
};

View file

@ -3466,6 +3466,9 @@ Zotero.Schema = new function(){
}
}
// TEMP: When adding 121, check whether IA.authorName fix in items.js::_loadAnnotations()
// should be updated
// If breaking compatibility or doing anything dangerous, clear minorUpdateFrom
}