# HG changeset patch # User Sebastien Jodogne # Date 1411387897 -7200 # Node ID f24e048380548090e6b8f823c736f71ba0801c13 # Parent 6fa65ccf312d142171cca99aefc1e74a3be5f677 fix diff -r 6fa65ccf312d -r f24e04838054 OrthancServer/PrepareDatabase.sql --- a/OrthancServer/PrepareDatabase.sql Mon Sep 22 13:57:04 2014 +0200 +++ b/OrthancServer/PrepareDatabase.sql Mon Sep 22 14:11:37 2014 +0200 @@ -18,7 +18,7 @@ PRIMARY KEY(id, tagGroup, tagElement) ); --- The following table was added in Orthanc 0.8.4 (database v5) +-- The following table was added in Orthanc 0.8.5 (database v5) CREATE TABLE DicomIdentifiers( id INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE, tagGroup INTEGER, @@ -77,11 +77,11 @@ CREATE INDEX PatientRecyclingIndex ON PatientRecyclingOrder(patientId); CREATE INDEX MainDicomTagsIndex1 ON MainDicomTags(id); --- The 2 following indexes were removed in Orthanc 0.8.4 (database v5), to speed up +-- The 2 following indexes were removed in Orthanc 0.8.5 (database v5), to speed up -- CREATE INDEX MainDicomTagsIndex2 ON MainDicomTags(tagGroup, tagElement); -- CREATE INDEX MainDicomTagsIndexValues ON MainDicomTags(value COLLATE BINARY); --- The 3 following indexes were added in Orthanc 0.8.4 (database v5) +-- The 3 following indexes were added in Orthanc 0.8.5 (database v5) CREATE INDEX DicomIdentifiersIndex1 ON DicomIdentifiers(id); CREATE INDEX DicomIdentifiersIndex2 ON DicomIdentifiers(tagGroup, tagElement); CREATE INDEX DicomIdentifiersIndexValues ON DicomIdentifiers(value COLLATE BINARY); @@ -100,7 +100,7 @@ CREATE TRIGGER ResourceDeleted AFTER DELETE ON Resources BEGIN - SELECT SignalResourceDeleted(old.publicId, old.resourceType); -- New in Orthanc 0.8.4 (db v5) + SELECT SignalResourceDeleted(old.publicId, old.resourceType); -- New in Orthanc 0.8.5 (db v5) SELECT SignalRemainingAncestor(parent.publicId, parent.resourceType) FROM Resources AS parent WHERE internalId = old.parentId; END; diff -r 6fa65ccf312d -r f24e04838054 OrthancServer/Upgrade4To5.sql --- a/OrthancServer/Upgrade4To5.sql Mon Sep 22 13:57:04 2014 +0200 +++ b/OrthancServer/Upgrade4To5.sql Mon Sep 22 14:11:37 2014 +0200 @@ -42,6 +42,7 @@ -- Upgrade the "ResourceDeleted" trigger DROP TRIGGER ResourceDeleted; +DROP TRIGGER ResourceDeletedParentCleaning; CREATE TRIGGER ResourceDeleted AFTER DELETE ON Resources @@ -51,6 +52,13 @@ FROM Resources AS parent WHERE internalId = old.parentId; END; +CREATE TRIGGER ResourceDeletedParentCleaning +AFTER DELETE ON Resources +FOR EACH ROW WHEN (SELECT COUNT(*) FROM Resources WHERE parentId = old.parentId) = 0 +BEGIN + DELETE FROM Resources WHERE internalId = old.parentId; +END; + -- Change the database version -- The "1" corresponds to the "GlobalProperty_DatabaseSchemaVersion" enumeration