From 3b4712d42f3f14d4c2e71928d0b9074dbab56b9d Mon Sep 17 00:00:00 2001 From: dullbananas Date: Fri, 22 Dec 2023 23:48:38 -0700 Subject: [PATCH] Update replaceable_schema.sql --- replaceable_schema.sql | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/replaceable_schema.sql b/replaceable_schema.sql index 1cfda3fe0..96d14ebab 100644 --- a/replaceable_schema.sql +++ b/replaceable_schema.sql @@ -65,6 +65,27 @@ CREATE TRIGGER aggregates FOR EACH STATEMENT EXECUTE FUNCTION r.community_aggregates_from_community (); +CREATE FUNCTION person_aggregates_from_person () + RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + INSERT INTO person_aggregates (person_id) + SELECT + id, + FROM + new_person; + + RETURN NULL; +END +$$; + +CREATE TRIGGER aggregates + AFTER INSERT ON person + REFERENCING NEW TABLE AS new_person + FOR EACH STATEMENT + EXECUTE FUNCTION r.person_aggregates_from_person (); + CREATE FUNCTION r.post_aggregates_from_post () RETURNS trigger LANGUAGE plpgsql