Giter VIP home page Giter VIP logo

audit-trigger's Introduction

A simple, customisable table audit system for PostgreSQL implemented using triggers.

See:

http://wiki.postgresql.org/wiki/Audit_trigger_91plus

update 2021-09-16

Added "ignored columns" feature

This feature is similar to the preexisting one "excluded columns" in the sense that it will ignore updates whose changes originated from the argument passed. However, the new feature will NOT exclude the provided columns from the "row_data" field in the audit table. This way, if you care about the changes in field B but ONLY when the field A updates, you should just ignore the column B, not exclude it.

Added "watched columns" feature

With this feature you can watch for changes in specific columns. For example, if you want to watch an order status column, you must pass '{order_status}::text[]' as an argument to the trigger creation call. Excluded columns takes precedence over ignored columns which takes precedence over watched columns.

Complete usage

SELECT audit.audit_table('public.my_table', 'true', 'true', '{}'::text[], '{a_column}'::text[], '{status_column}'::text[]);
Note the argument '{}'::text[] as the "excluded_cols" array parameter. Although we don't want to exclude any columns, we must pass an empty array as the argument of it, just because we are using the "ignored_cols" parameter.
If you don't want to exclude OR ignore any columns, then you may omit both arguments.

audit-trigger's People

Contributors

3nids avatar adtc avatar archaeogeek avatar asenyshyn avatar herzog0 avatar jeffreyhmcclelland avatar memoz avatar mikijov avatar paulovieira avatar ringerc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.