egdb3_12_9
.auditor
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
update_auditors()
Parameters
Name
Type
Mode
IN
Definition
DECLARE auditor_name TEXT; table_schema TEXT; table_name TEXT; BEGIN -- Drop Lifecycle view(s) before potential column changes FOR auditor_name IN SELECT c.relname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE relkind = 'v' AND n.nspname = 'auditor' LOOP EXECUTE $$ DROP VIEW auditor.$$ || auditor_name || $$;$$; END LOOP; -- Fix all column discrepencies PERFORM auditor.fix_columns(); -- Re-create trigger functions and lifecycle views FOR table_schema, table_name IN WITH audit_tables AS ( SELECT c.oid AS audit_oid, c.relname AS audit_table FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE relkind='r' AND nspname = 'auditor' ), table_set AS ( SELECT a.audit_oid, a.audit_table, c.oid AS main_oid, n.nspname as main_namespace, c.relname as main_table FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace JOIN audit_tables a ON a.audit_table = n.nspname || '_' || c.relname || '_history' WHERE relkind = 'r' ) SELECT main_namespace, main_table FROM table_set LOOP PERFORM auditor.create_auditor_func(table_schema, table_name); PERFORM auditor.create_auditor_lifecycle(table_schema, table_name); END LOOP; RETURN TRUE; END;