From 9596cece44b46a0ac0fbe4910f6283fd29a2723e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 7 Jul 2008 14:00:34 +0000 Subject: [PATCH] Add UNIQUE index on itemDataValues values --- chrome/content/zotero/xpcom/schema.js | 12 ++++++++++++ userdata.sql | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index fd3a6edf79..8531478b20 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -1415,6 +1415,18 @@ Zotero.Schema = new function(){ statement.reset(); Zotero.DB.query("CREATE UNIQUE INDEX items_key ON items(key)"); + var rows = Zotero.DB.columnQuery("SELECT GROUP_CONCAT(valueID) FROM itemDataValues GROUP BY value HAVING COUNT(*) > 1"); + for each(var row in rows) { + var ids = row.split(','); + var deleteIDs = []; + for (var j=1; j