Schema update step to fix invalid item relations
As corrected in d0a110072
This commit is contained in:
parent
d0a110072b
commit
560eb37d0b
2 changed files with 12 additions and 1 deletions
|
@ -2245,6 +2245,17 @@ Zotero.Schema = new function(){
|
|||
else if (i == 85) {
|
||||
yield Zotero.DB.queryAsync("DELETE FROM version WHERE schema IN ('sync', 'syncdeletelog')");
|
||||
}
|
||||
|
||||
else if (i == 86) {
|
||||
let rows = yield Zotero.DB.queryAsync("SELECT ROWID AS id, * FROM itemRelations WHERE SUBSTR(object, 1, 18)='http://zotero.org/' AND NOT INSTR(object, 'item')");
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
// http://zotero.org/users/local/aFeGasdGSdH/8QZ36WQ3 -> http://zotero.org/users/local/aFeGasdGSdH/items/8QZ36WQ3
|
||||
// http://zotero.org/users/12341/8QZ36WQ3 -> http://zotero.org/users/12341/items/8QZ36WQ3
|
||||
// http://zotero.org/groups/12341/8QZ36WQ3 -> http://zotero.org/groups/12341/items/8QZ36WQ3
|
||||
let newObject = rows[i].object.replace(/^(http:\/\/zotero.org\/(?:(?:users|groups)\/\d+|users\/local\/[^\/]+))\/([A-Z0-9]{8})$/, '$1/items/$2');
|
||||
yield Zotero.DB.queryAsync("UPDATE itemRelations SET object=? WHERE ROWID=?", [newObject, rows[i].id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yield _updateDBVersion('userdata', toVersion);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
-- 85
|
||||
-- 86
|
||||
|
||||
-- Copyright (c) 2009 Center for History and New Media
|
||||
-- George Mason University, Fairfax, Virginia, USA
|
||||
|
|
Loading…
Add table
Reference in a new issue