Delete child annotations when deleting attachment

And fix a FK definition that could result in orphaned `items` rows
without `itemAnnotations` rows after an attachment was deleted.
This commit is contained in:
Dan Stillman 2021-03-12 06:28:37 -05:00
parent 0bc6b2ccc6
commit 76d504c564
3 changed files with 52 additions and 12 deletions

View file

@ -1,4 +1,4 @@
-- 112
-- 113
-- Copyright (c) 2009 Center for History and New Media
-- George Mason University, Fairfax, Virginia, USA
@ -127,7 +127,7 @@ CREATE TABLE itemAnnotations (
position TEXT NOT NULL,
isExternal INT NOT NULL,
FOREIGN KEY (itemID) REFERENCES items(itemID) ON DELETE CASCADE,
FOREIGN KEY (parentItemID) REFERENCES itemAttachments(itemID) ON DELETE CASCADE
FOREIGN KEY (parentItemID) REFERENCES itemAttachments(itemID)
);
CREATE INDEX itemAnnotations_parentItemID ON itemAnnotations(parentItemID);