pgMemento v0.4
Changelog
This is a BIG release to me which includes many very important improvements (highlights are marked):
- Now requires PostgreSQL 9.5 because for using to_jsonb, jsonb_agg, pg_event_trigger_ddl_commands() and UPSERT
- Let the user decide to log existing data during initialization of pgMemento
SETUP:
- A table operation type is only logged once per transaction, which greatly improves the performance of deleting data while auditing
- Have only one unique index on
table_event_log
table (transaction_id, table_relid, op_id) - New ID column in
audit_table_log
in order to log renamed versions - Two new event types are logged in
table_event_log
table:ALTER COLUMN
andDROP COLUMN
(see DDL_LOG changes) - If UPDATEs did not change anything, nothing will be logged
- Extra option for function
create_table_audit
to log existing data as inserted (log_table_state
) - Moved
log_table_state
function from VERSIONING.sql to SETUP.sql - Function
log_schema_state
is using the dependency depth fromaudit_tables_dependency
to mark INSERTs in correct order
LOG_UTIL:
- New VIEW
audit_tables_dependency
to make reverts and other schema-based procedures more robust - Bugfix in
get_txid_bounds_to_table
function to create a correctaudit_tables
view - Moved VIEWs and
get_txid_bounds_to_table
to SETUP.sql - Custom aggregate function
jsonb_merge
to merge JSONB objects (very helpful forrevert_distinct_transaction
)
VERSIONING:
- Improved performance for restoring historic versions of tuples, tables and databases
- New function
generate_log_entries
to look at a past table state without creating a TABLE or VIEW - Code split up into several functions to reduce redundancy
- Templates for
jsonb_populate_record
can now be created withcreate_restore_template
to be used for on-the-fly restores - Restore process queries recent state only if exists and considers renaming of tables and columns
- All restored tables are created with an
CREATE TABLE AS
command to avoid firing the event trigger
REVERT:
- Reverts are no longer limited to non-cascading operations
- Reverts are using the dependency depth from
audit_tables_dependency
view what makes them more robust against foreign key violations - Removed buggy merging option from
recover_audit_version
. - Creating distinct changes for JSONB fields ordered by age with
jsonb_merge
trick
DDL_LOG:
- New event triggers will prevent data loss when
DROP [SCHEMA, TABLE, COLUMN]
orALTER COLUMN ... TYPE ... USING
events occur - New names for event triggers and rewritten functions
- Trigger for
CREATE TABLE
events will not fire for temprary tables - Logging also
CREATE TABLE
,DROP TABLE
andADD COLUMN
events intransaction_log
andtable_event_log