Mercurial > hg > orthanc
comparison OrthancServer/Database/InstallTrackAttachmentsSize.sql @ 3094:61da3c9b4121 db-changes
cont reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 05 Jan 2019 17:52:24 +0100 |
parents | OrthancServer/InstallTrackAttachmentsSize.sql@8336204d95dc |
children |
comparison
equal
deleted
inserted
replaced
3093:2e1808b6146a | 3094:61da3c9b4121 |
---|---|
1 CREATE TABLE GlobalIntegers( | |
2 key INTEGER PRIMARY KEY, | |
3 value INTEGER); | |
4 | |
5 INSERT INTO GlobalProperties VALUES (6, 1); -- GlobalProperty_GetTotalSizeIsFast | |
6 | |
7 INSERT INTO GlobalIntegers SELECT 0, IFNULL(SUM(compressedSize), 0) FROM AttachedFiles; | |
8 INSERT INTO GlobalIntegers SELECT 1, IFNULL(SUM(uncompressedSize), 0) FROM AttachedFiles; | |
9 | |
10 CREATE TRIGGER AttachedFileIncrementSize | |
11 AFTER INSERT ON AttachedFiles | |
12 BEGIN | |
13 UPDATE GlobalIntegers SET value = value + new.compressedSize WHERE key = 0; | |
14 UPDATE GlobalIntegers SET value = value + new.uncompressedSize WHERE key = 1; | |
15 END; | |
16 | |
17 CREATE TRIGGER AttachedFileDecrementSize | |
18 AFTER DELETE ON AttachedFiles | |
19 BEGIN | |
20 UPDATE GlobalIntegers SET value = value - old.compressedSize WHERE key = 0; | |
21 UPDATE GlobalIntegers SET value = value - old.uncompressedSize WHERE key = 1; | |
22 END; |