Back
- Download history_create_triggers
CREATE OR REPLACE FUNCTION history_create_triggers(schema text) RETURNS void AS $$ DECLARE r RECORD; BEGIN FOR r IN SELECT table_name FROM information_schema.tables WHERE table_schema = schema LOOP EXECUTE 'CREATE TRIGGER log_history AFTER INSERT OR UPDATE OR DELETE ON ' || schema || '.' || r.table_name || ' FOR EACH ROW EXECUTE PROCEDURE log_history();'; END LOOP; END; $$ LANGUAGE plpgsql;