{"id":14974083,"url":"https://github.com/asolovey/postgresql-audit-log","last_synced_at":"2026-03-04T13:03:01.000Z","repository":{"id":70876787,"uuid":"91650734","full_name":"asolovey/postgresql-audit-log","owner":"asolovey","description":"Simple, trigger-based audit log for PostgreSQL tables.","archived":false,"fork":false,"pushed_at":"2023-04-24T06:02:17.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-09T06:15:15.837Z","etag":null,"topics":["dba","plpgsql","postgresql"],"latest_commit_sha":null,"homepage":"","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asolovey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audit.sql","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-18T05:04:27.000Z","updated_at":"2023-09-28T22:47:19.000Z","dependencies_parsed_at":"2024-10-11T10:10:42.160Z","dependency_job_id":null,"html_url":"https://github.com/asolovey/postgresql-audit-log","commit_stats":{"total_commits":3,"total_committers":3,"mean_commits":1.0,"dds":0.6666666666666667,"last_synced_commit":"3fdad3637fe5277d74051cbde56da8679276f1c2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asolovey%2Fpostgresql-audit-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asolovey%2Fpostgresql-audit-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asolovey%2Fpostgresql-audit-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asolovey%2Fpostgresql-audit-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asolovey","download_url":"https://codeload.github.com/asolovey/postgresql-audit-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240859651,"owners_count":19869186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dba","plpgsql","postgresql"],"created_at":"2024-09-24T13:49:55.796Z","updated_at":"2026-03-04T13:03:00.961Z","avatar_url":"https://github.com/asolovey.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostgreSQL Table Audit Log\n\nSimple, trigger-based audit log for PostgreSQL tables.\n\nUse `audit.sql` to add audit table `t_audit_log`, trigger function `f_audit`\nand a few utility functions to your database. Create `AFTER INSERT OR UPDATE OR DELETE`\ntrigger on any table to keep the log for.\n\nAccording to https://www.postgresql.org/docs/current/static/trigger-definition.html\n\n    If more than one trigger is defined for the same event on the same relation,\n    the triggers will be fired in alphabetical order by trigger name.\n\nTherefore, use a name like \"zz_audit\" for audit trigger to ensure that it fires after other\ntriggers and records changes made by those triggers.\n\n## Examples\n\n### Simple case: default primary key, no excluded columns.\n\n```sql\nCREATE TABLE t_user (\n     id            SERIAL PRIMARY KEY\n    ,name          TEXT NOT NULL\n    ,email         TEXT NOT NULL\n    ,admin         BOOLEAN NOT NULL DEFAULT FALSE\n);\n\nCREATE TRIGGER zz_audit AFTER INSERT OR UPDATE OR DELETE ON t_user\n    FOR EACH ROW EXECUTE PROCEDURE f_audit();\n```\n\n### No primary key (or it is unusable), so unique row identifier columns are listed explicitly\n\n```sql\nCREATE TABLE t_tag (\n     user_id    INT CHECK( user_id != 0 )\n    ,account_id INT CHECK( account_id != 0 )\n    ,company_id INT CHECK( company_id != 0 )\n    ,name       TEXT NOT NULL\n);\n\n/* Cannot use nullable columns in primary key, so unique constraint instead: */\nCREATE UNIQUE INDEX u_tag ON t_tag( COALESCE( user_id, 0 ), COALESCE( account_id, 0 ), COALESCE( company_id, 0 ) );\n\nCREATE TRIGGER zz_audit AFTER INSERT OR UPDATE OR DELETE ON t_tag\n    FOR EACH ROW EXECUTE PROCEDURE f_audit('{\"user_id\", \"account_id\", \"company_id\"}');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasolovey%2Fpostgresql-audit-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasolovey%2Fpostgresql-audit-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasolovey%2Fpostgresql-audit-log/lists"}