You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
REVOKE ALL ON app_audit.logged_actions FROM public;
63
-
64
-
COMMENT ON TABLE app_audit.logged_actions IS 'History of auditable actions on audited tables, from app_audit.if_modified_func()';
65
-
COMMENT ON COLUMN app_audit.logged_actions.event_id IS 'Unique identifier for each auditable event';
66
-
COMMENT ON COLUMN app_audit.logged_actions.schema_name IS 'Database schema audited table for this event is in';
67
-
COMMENT ON COLUMN app_audit.logged_actions.table_name IS 'Non-schema-qualified table name of table event occurred in';
68
-
COMMENT ON COLUMN app_audit.logged_actions.relid IS 'Table OID. Changes with drop/create. Get with ''tablename''::regclass';
69
-
COMMENT ON COLUMN app_audit.logged_actions.session_user_name IS 'Login / session user whose statement caused the audited event';
70
-
COMMENT ON COLUMN app_audit.logged_actions.action_tstamp_tx IS 'Transaction start timestamp for tx in which audited event occurred';
71
-
COMMENT ON COLUMN app_audit.logged_actions.action_tstamp_stm IS 'Statement start timestamp for tx in which audited event occurred';
72
-
COMMENT ON COLUMN app_audit.logged_actions.action_tstamp_clk IS 'Wall clock time at which audited event''s trigger call occurred';
73
-
COMMENT ON COLUMN app_audit.logged_actions.transaction_id IS 'Identifier of transaction that made the change. May wrap, but unique paired with action_tstamp_tx.';
74
-
COMMENT ON COLUMN app_audit.logged_actions.client_addr IS 'IP address of client that issued query. Null for unix domain socket.';
75
-
COMMENT ON COLUMN app_audit.logged_actions.client_port IS 'Remote peer IP port address of client that issued query. Undefined for unix socket.';
76
-
COMMENT ON COLUMN app_audit.logged_actions.client_query IS 'Top-level query that caused this auditable event. May be more than one statement.';
77
-
COMMENT ON COLUMN app_audit.logged_actions.application_name IS 'Application name set when this audit event occurred. Can be changed in-session by client.';
78
-
COMMENT ON COLUMN app_audit.logged_actions.action IS 'Action type; I = insert, D = delete, U = update, T = truncate';
79
-
COMMENT ON COLUMN app_audit.logged_actions.row_data IS 'Record value. Null for statement-level trigger. For INSERT this is the new tuple. For DELETE and UPDATE it is the old tuple.';
80
-
COMMENT ON COLUMN app_audit.logged_actions.changed_fields IS 'New values of fields changed by UPDATE. Null except for row-level UPDATE events.';
81
-
COMMENT ON COLUMN app_audit.logged_actions.statement_only IS '''t'' if audit event is from an FOR EACH STATEMENT trigger, ''f'' for FOR EACH ROW';
82
-
83
-
CREATE INDEX logged_actions_relid_idx ON app_audit.logged_actions(relid);
84
-
CREATE INDEX logged_actions_action_tstamp_tx_stm_idx ON app_audit.logged_actions(action_tstamp_stm);
85
-
CREATE INDEX logged_actions_action_idx ON app_audit.logged_actions(action);
86
-
87
-
CREATE OR REPLACE FUNCTION app_audit.if_modified_func() RETURNS TRIGGER AS $body$
64
+
REVOKE ALL ON ${auditSchema}.logged_actions FROM public;
65
+
66
+
COMMENT ON TABLE ${auditSchema}.logged_actions IS 'History of auditable actions on audited tables, from ${auditSchema}.if_modified_func()';
67
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.event_id IS 'Unique identifier for each auditable event';
68
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.schema_name IS 'Database schema audited table for this event is in';
69
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.table_name IS 'Non-schema-qualified table name of table event occurred in';
70
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.relid IS 'Table OID. Changes with drop/create. Get with ''tablename''::regclass';
71
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.session_user_name IS 'Login / session user whose statement caused the audited event';
72
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.action_tstamp_tx IS 'Transaction start timestamp for tx in which audited event occurred';
73
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.action_tstamp_stm IS 'Statement start timestamp for tx in which audited event occurred';
74
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.action_tstamp_clk IS 'Wall clock time at which audited event''s trigger call occurred';
75
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.transaction_id IS 'Identifier of transaction that made the change. May wrap, but unique paired with action_tstamp_tx.';
76
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.client_addr IS 'IP address of client that issued query. Null for unix domain socket.';
77
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.client_port IS 'Remote peer IP port address of client that issued query. Undefined for unix socket.';
78
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.client_query IS 'Top-level query that caused this auditable event. May be more than one statement.';
79
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.application_name IS 'Application name set when this audit event occurred. Can be changed in-session by client.';
80
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.action IS 'Action type; I = insert, D = delete, U = update, T = truncate';
81
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.row_data IS 'Record value. Null for statement-level trigger. For INSERT this is the new tuple. For DELETE and UPDATE it is the old tuple.';
82
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.changed_fields IS 'New values of fields changed by UPDATE. Null except for row-level UPDATE events.';
83
+
COMMENT ON COLUMN ${auditSchema}.logged_actions.statement_only IS '''t'' if audit event is from an FOR EACH STATEMENT trigger, ''f'' for FOR EACH ROW';
84
+
85
+
CREATE INDEX logged_actions_relid_idx ON ${auditSchema}.logged_actions(relid);
86
+
CREATE INDEX logged_actions_action_tstamp_tx_stm_idx ON ${auditSchema}.logged_actions(action_tstamp_stm);
87
+
CREATE INDEX logged_actions_action_idx ON ${auditSchema}.logged_actions(action);
88
+
89
+
CREATE OR REPLACE FUNCTION ${auditSchema}.if_modified_func() RETURNS TRIGGER AS $body$
88
90
DECLARE
89
-
audit_row app_audit.logged_actions;
91
+
audit_row ${auditSchema}.logged_actions;
90
92
include_values boolean;
91
93
log_diffs boolean;
92
94
h_old hstore;
93
95
h_new hstore;
94
96
excluded_cols text[] = ARRAY[]::text[];
95
97
BEGIN
96
98
IF TG_WHEN <> 'AFTER' THEN
97
-
RAISE EXCEPTION 'app_audit.if_modified_func() may only run as an AFTER trigger';
99
+
RAISE EXCEPTION '${auditSchema}.if_modified_func() may only run as an AFTER trigger';
0 commit comments