Logging can be stopped and restarted per schema. This removes log triggers but keeps the audit_id column in audited tables. These tables are still listed in the audit_tables view, showing triggers are disabled. The transaction id ranges in audit_schema_log
and audit_table_log
remain open. They are only closed if auditing is dropped.
Auditing can be paused either by calling pgmemento.stop
or by running the interactive STOP_AUDITING.sql
script. You can specify:
- The schema, where you want to stop/start logging and
- define a set of tables you want to exclude from the action (comma-separated list)
The function or script should finish with the message "pgMemento is stopped for
Pause logging for single tables
If you only want to pause/deactivate logging for a single table use the pgmemento.drop_table_log_trigger
function:
sql
SELECT pgmemento.drop_table_log_trigger('table_A', 'public');
Restart auditing
To start auditing again you can call pgmemento.start
or run the START_AUDITING
script. This will only work if pgMemento is already initialized in the schema and registered in the audit_schema_log
. The start
endpoint offers the same options than init except that you cannot log the existing content of tables. If you choose a different logging behavior or default name for the audit_id
column, the reinit
endpoint is called, hence a new entry is written to the audit_schema_log
.
Create log triggers for a single table
If you want to recreate the log triggers for a single table and don't want to use the start
endpoint by excluding every other table, call the following function:
sql
SELECT pgmemento.create_table_log_trigger(
table_name := 'table_A',
schema_name := 'public',
audit_id_column_name := 'pgmemento_audit_id',
log_old_data := TRUE,
log_new_data := FALSE
);