1 create or replace function comment_aggregates_comment()
2 returns trigger language plpgsql
5 IF (TG_OP = 'INSERT') THEN
6 insert into comment_aggregates (comment_id) values (NEW.id);
7 ELSIF (TG_OP = 'DELETE') THEN
8 delete from comment_aggregates where comment_id = OLD.id;
13 create or replace function post_aggregates_post()
14 returns trigger language plpgsql
17 IF (TG_OP = 'INSERT') THEN
18 insert into post_aggregates (post_id) values (NEW.id);
19 ELSIF (TG_OP = 'DELETE') THEN
20 delete from post_aggregates where post_id = OLD.id;
25 create or replace function community_aggregates_community()
26 returns trigger language plpgsql
29 IF (TG_OP = 'INSERT') THEN
30 insert into community_aggregates (community_id) values (NEW.id);
31 ELSIF (TG_OP = 'DELETE') THEN
32 delete from community_aggregates where community_id = OLD.id;