We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 91223e8 commit 0a876b8Copy full SHA for 0a876b8
audit_listen.sql
@@ -0,0 +1,20 @@
1
+CREATE OR REPLACE FUNCTION audit.notify_audit_logged_action_channel()
2
+ RETURNS TRIGGER AS $$
3
+DECLARE
4
+ payload json;
5
+BEGIN
6
+ payload := json_build_object(
7
+ 'event_id', NEW.event_id,
8
+ 'schema_name', NEW.schema_name,
9
+ 'table_name', NEW.table_name,
10
+ 'action', NEW.action,
11
+ 'statement_only', NEW.statement_only
12
+ );
13
+ PERFORM pg_notify('audit_logged_action', payload::text);
14
+ RETURN NEW;
15
+END;
16
+$$ LANGUAGE plpgsql;
17
+
18
+CREATE OR REPLACE TRIGGER trigger_notify_action_channel
19
+AFTER INSERT ON audit.logged_actions
20
+FOR EACH ROW EXECUTE FUNCTION audit.notify_audit_logged_action_channel();
0 commit comments