I have a table with a trigger that updates a "modified" timestamp whenever the record changes. I did it with a BEFORE trigger:
CREATE OR REPLACE FUNCTION update_modified()
RETURNS trigger AS
$$
BEGIN
NEW.modified = now();
RETURN NEW;
END;
$$
LANGUAGE plpgsql;
CREATE TRIGGER contact_update_modified
BEFORE UPDATE
ON contacts
FOR EACH ROW
EXECUTE PROCEDURE update_modified();
Then I partitioned the table, and when I try to add the trigger, I get:
ERROR: "contacts" is a partitioned table
DETAIL: Partitioned tables cannot have BEFORE / FOR EACH ROW triggers.
SQL state: 42809
If I change it to an AFTER trigger it doesn't update the modified field (which makes sense).
It appears that it does work if I add the trigger to each child partition table manually. I can do this, but it's not ideal. Is there a better way?