Remove invalid relations mangled during import

Not sure if this occurred for our own translators, but it addresses
items created from #1282.
This commit is contained in:
Dan Stillman 2017-09-22 01:22:33 -04:00
parent 0d3d4323b5
commit a455a72534
2 changed files with 11 additions and 1 deletions

View file

@ -2469,6 +2469,16 @@ Zotero.Schema = new function(){
yield Zotero.DB.queryAsync("REPLACE INTO fileTypeMIMETypes VALUES(7, 'application/vnd.ms-powerpoint')");
}
else if (i == 97) {
let where = "WHERE predicate IN (" + Array.from(Array(20).keys()).map(i => `'${i}'`).join(', ') + ")";
let rows = yield Zotero.DB.queryAsync("SELECT * FROM relationPredicates " + where);
for (let row of rows) {
yield Zotero.DB.columnQueryAsync("UPDATE items SET synced=0 WHERE itemID IN (SELECT itemID FROM itemRelations WHERE predicateID=?)", row.predicateID);
yield Zotero.DB.queryAsync("DELETE FROM itemRelations WHERE predicateID=?", row.predicateID);
}
yield Zotero.DB.queryAsync("DELETE FROM relationPredicates " + where);
}
// If breaking compatibility or doing anything dangerous, clear minorUpdateFrom
}

View file

@ -1,4 +1,4 @@
-- 96
-- 97
-- Copyright (c) 2009 Center for History and New Media
-- George Mason University, Fairfax, Virginia, USA