Mercurial > hg > orthanc
comparison OrthancServer/Upgrade4To5.sql @ 1176:f24e04838054 db-changes
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 22 Sep 2014 14:11:37 +0200 |
parents | 8f9d49192815 |
children |
comparison
equal
deleted
inserted
replaced
1175:6fa65ccf312d | 1176:f24e04838054 |
---|---|
40 | 40 |
41 | 41 |
42 -- Upgrade the "ResourceDeleted" trigger | 42 -- Upgrade the "ResourceDeleted" trigger |
43 | 43 |
44 DROP TRIGGER ResourceDeleted; | 44 DROP TRIGGER ResourceDeleted; |
45 DROP TRIGGER ResourceDeletedParentCleaning; | |
45 | 46 |
46 CREATE TRIGGER ResourceDeleted | 47 CREATE TRIGGER ResourceDeleted |
47 AFTER DELETE ON Resources | 48 AFTER DELETE ON Resources |
48 BEGIN | 49 BEGIN |
49 SELECT SignalResourceDeleted(old.publicId, old.resourceType); | 50 SELECT SignalResourceDeleted(old.publicId, old.resourceType); |
50 SELECT SignalRemainingAncestor(parent.publicId, parent.resourceType) | 51 SELECT SignalRemainingAncestor(parent.publicId, parent.resourceType) |
51 FROM Resources AS parent WHERE internalId = old.parentId; | 52 FROM Resources AS parent WHERE internalId = old.parentId; |
52 END; | 53 END; |
53 | 54 |
55 CREATE TRIGGER ResourceDeletedParentCleaning | |
56 AFTER DELETE ON Resources | |
57 FOR EACH ROW WHEN (SELECT COUNT(*) FROM Resources WHERE parentId = old.parentId) = 0 | |
58 BEGIN | |
59 DELETE FROM Resources WHERE internalId = old.parentId; | |
60 END; | |
61 | |
54 | 62 |
55 -- Change the database version | 63 -- Change the database version |
56 -- The "1" corresponds to the "GlobalProperty_DatabaseSchemaVersion" enumeration | 64 -- The "1" corresponds to the "GlobalProperty_DatabaseSchemaVersion" enumeration |
57 | 65 |
58 UPDATE GlobalProperties SET value="5" WHERE property=1; | 66 UPDATE GlobalProperties SET value="5" WHERE property=1; |