1 CREATE OR REPLACE FUNCTION site_aggregates_site ()
6 -- we only ever want to have a single value in site_aggregate because the site_aggregate triggers update all rows in that table.
7 -- a cleaner check would be to insert it for the local_site but that would break assumptions at least in the tests
8 IF (TG_OP = 'INSERT') AND NOT EXISTS (
14 INSERT INTO site_aggregates (site_id)
16 ELSIF (TG_OP = 'DELETE') THEN
17 DELETE FROM site_aggregates
18 WHERE site_id = OLD.id;
24 DELETE FROM site_aggregates a
31 s.site_id = a.site_id);