Remove any remaining blank tags and enforce on DB level

This commit is contained in:
Dan Stillman 2009-12-02 08:11:37 +00:00
parent 6539cace59
commit 0fe5389858
3 changed files with 25 additions and 2 deletions

View file

@ -2487,6 +2487,11 @@ Zotero.Schema = new function(){
Zotero.DB.query("UPDATE itemNotes SET sourceItemID=NULL WHERE sourceItemID IN (SELECT itemID FROM items WHERE itemTypeID IN (1,14))");
}
if (i==66) {
Zotero.DB.query("DELETE FROM itemTags WHERE tagID IN (SELECT tagID FROM tags WHERE TRIM(name)='')");
Zotero.DB.query("DELETE FROM tags WHERE TRIM(name)=''");
}
Zotero.wait();
}

View file

@ -1,4 +1,4 @@
-- 14
-- 15
-- Triggers to validate date field
DROP TRIGGER IF EXISTS insert_date_field;
@ -1388,3 +1388,21 @@ CREATE TRIGGER fku_proxies_proxyID_proxyHosts_proxyID
SELECT RAISE(ABORT, 'update on table "proxies" violates foreign key constraint "fku_proxies_proxyID_proxyHosts_proxyID"')
WHERE (SELECT COUNT(*) FROM proxyHosts WHERE proxyID = OLD.proxyID) > 0;
END;
-- Make sure tags aren't empty
DROP TRIGGER IF EXISTS fki_tags;
CREATE TRIGGER fki_tags
BEFORE INSERT ON tags
FOR EACH ROW BEGIN
SELECT RAISE(ABORT, 'Tag cannot be blank')
WHERE TRIM(NEW.name)='';
END;
DROP TRIGGER IF EXISTS fku_tags;
CREATE TRIGGER fku_tags
BEFORE UPDATE OF name ON tags
FOR EACH ROW BEGIN
SELECT RAISE(ABORT, 'Tag cannot be blank')
WHERE TRIM(NEW.name)='';
END;

View file

@ -1,4 +1,4 @@
-- 65
-- 66
-- This file creates tables containing user-specific data for new users --
-- any changes made here must be mirrored in transition steps in schema.js::_migrateSchema()