comparison artifact-database/doc/schema-pg.sql @ 229:328ef982d768

When an artifact is touched the collections which contain the artifact are touched, too. artifacts/trunk@1631 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 31 Mar 2011 08:58:42 +0000
parents face2302387c
children 92166f7c3842
comparison
equal deleted inserted replaced
228:dd977fb7552e 229:328ef982d768
48 artifact_id int NOT NULL REFERENCES artifacts(id), 48 artifact_id int NOT NULL REFERENCES artifacts(id),
49 attribute bytea, 49 attribute bytea,
50 UNIQUE (collection_id, artifact_id) 50 UNIQUE (collection_id, artifact_id)
51 ); 51 );
52 52
53 CREATE FUNCTION collections_access_update() RETURNS trigger AS
54 $$
55 BEGIN
56 UPDATE collections SET last_access = current_timestamp
57 WHERE id IN
58 (SELECT c.id FROM collections c
59 INNER JOIN collection_items ci ON c.id = ci.collection_id
60 INNER JOIN artifacts a ON a.id = ci.artifact_id
61 WHERE a.id = NEW.id);
62 RETURN NEW;
63 END;
64 $$
65 LANGUAGE 'plpgsql';
66
67
68 CREATE TRIGGER collections_access_update_trigger AFTER UPDATE
69 ON artifacts FOR EACH ROW
70 EXECUTE PROCEDURE collections_access_update();
71
53 COMMIT; 72 COMMIT;

http://dive4elements.wald.intevation.org