Merge remote-tracking branch 'origin/main' into combined_profile

This commit is contained in:
Dessalines 2024-12-19 17:53:24 -05:00
commit a1792bb16e

View file

@ -761,3 +761,35 @@ CALL r.create_person_saved_combined_trigger ('post');
CALL r.create_person_saved_combined_trigger ('comment'); CALL r.create_person_saved_combined_trigger ('comment');
-- Combined tables triggers
-- These insert (published, item_id) into X_combined tables
-- Reports (comment_report, post_report, private_message_report)
CREATE PROCEDURE r.create_report_combined_trigger (table_name text)
LANGUAGE plpgsql
AS $a$
BEGIN
EXECUTE replace($b$ CREATE FUNCTION r.report_combined_thing_insert ( )
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
BEGIN
INSERT INTO report_combined (published, thing_id)
VALUES (NEW.published, NEW.id);
RETURN NEW;
END $$;
CREATE TRIGGER report_combined
AFTER INSERT ON thing
FOR EACH ROW
EXECUTE FUNCTION r.report_combined_thing_insert ( );
$b$,
'thing',
table_name);
END;
$a$;
CALL r.create_report_combined_trigger ('post_report');
CALL r.create_report_combined_trigger ('comment_report');
CALL r.create_report_combined_trigger ('private_message_report');