Mercurial > dive4elements > framework
diff 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 |
line wrap: on
line diff
--- a/artifact-database/doc/schema-pg.sql Thu Mar 31 08:42:53 2011 +0000 +++ b/artifact-database/doc/schema-pg.sql Thu Mar 31 08:58:42 2011 +0000 @@ -50,4 +50,23 @@ UNIQUE (collection_id, artifact_id) ); +CREATE FUNCTION collections_access_update() RETURNS trigger AS +$$ +BEGIN + UPDATE collections SET last_access = current_timestamp + WHERE id IN + (SELECT c.id FROM collections c + INNER JOIN collection_items ci ON c.id = ci.collection_id + INNER JOIN artifacts a ON a.id = ci.artifact_id + WHERE a.id = NEW.id); + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + + +CREATE TRIGGER collections_access_update_trigger AFTER UPDATE + ON artifacts FOR EACH ROW + EXECUTE PROCEDURE collections_access_update(); + COMMIT;