Fixing the comment delete trigger

This commit is contained in:
Dessalines 2020-07-05 00:18:18 -04:00
parent 5a88a6ecdc
commit 377f76a018

View file

@ -338,7 +338,11 @@ begin
delete from comment_aggregates_fast where id = OLD.id;
-- Update community number of comments
update community_aggregates_fast set number_of_comments = number_of_comments - 1 from post where id = post.community_id and post.id = NEW.post_id;
update community_aggregates_fast as caf
set number_of_comments = number_of_comments - 1
from post as p
where caf.id = p.community_id and p.id = OLD.post_id;
ELSIF (TG_OP = 'UPDATE') THEN
delete from comment_aggregates_fast where id = OLD.id;
insert into comment_aggregates_fast select * from comment_aggregates_view where id = NEW.id;