From 30e4ae859da12904167803ecff4dfcfc9198014f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 25 Jul 2008 19:00:44 +0000 Subject: [PATCH] Fix "data mismatch" error, for real --- chrome/content/zotero/xpcom/schema.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 2b7ad20b4..cae47e860 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -1632,8 +1632,14 @@ Zotero.Schema = new function(){ // Migrate big integers var itemIDs = Zotero.DB.columnQuery("SELECT itemID FROM items WHERE itemID>16777215"); + var smalls = Zotero.DB.columnQuery("SELECT itemID FROM items WHERE itemID<300000"); + var newID = Math.max.apply(this, smalls); for each(var oldID in itemIDs) { - var newID = Zotero.ID.get('items'); + do { + newID = newID + 1; + var exists = Zotero.DB.valueQuery("SELECT COUNT(*) FROM items WHERE itemID=?", newID); + } + while (exists); var params = [newID, oldID]; Zotero.DB.query("UPDATE items SET itemID=? WHERE itemID=?", params); Zotero.DB.query("UPDATE annotations SET itemID=? WHERE itemID=?", params);