{"id":34847660,"url":"https://github.com/richwrd/postgres-audit-log","last_synced_at":"2026-05-24T03:32:58.140Z","repository":{"id":287496393,"uuid":"964927368","full_name":"richwrd/postgres-audit-log","owner":"richwrd","description":"Lightweight and extensible PostgreSQL DML audit solution - Automatic trigger management, per-schema control, structured JSONB logs for tracking INSERT, UPDATE, and DELETE operations.","archived":false,"fork":false,"pushed_at":"2026-04-08T00:00:29.000Z","size":6020,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-24T03:32:51.973Z","etag":null,"topics":["auditing","change-tracking","database-audit","database-security","dml","jsonb","logging","logging-system","pgpartman","plpgsql","postgresql","triggers"],"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/richwrd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-12T03:39:32.000Z","updated_at":"2026-04-08T00:01:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"d74d36c7-b56e-4857-98fd-2c2b6a34fdf7","html_url":"https://github.com/richwrd/postgres-audit-log","commit_stats":null,"previous_names":["richwrd/pgauditgraph","richwrd/postgres-audit-log"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/richwrd/postgres-audit-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richwrd%2Fpostgres-audit-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richwrd%2Fpostgres-audit-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richwrd%2Fpostgres-audit-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richwrd%2Fpostgres-audit-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richwrd","download_url":"https://codeload.github.com/richwrd/postgres-audit-log/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richwrd%2Fpostgres-audit-log/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33420660,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T22:14:44.296Z","status":"online","status_checked_at":"2026-05-24T02:00:06.296Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["auditing","change-tracking","database-audit","database-security","dml","jsonb","logging","logging-system","pgpartman","plpgsql","postgresql","triggers"],"created_at":"2025-12-25T18:52:39.642Z","updated_at":"2026-05-24T03:32:58.135Z","avatar_url":"https://github.com/richwrd.png","language":"PLpgSQL","funding_links":["https://www.buymeacoffee.com/richwrd"],"categories":[],"sub_categories":[],"readme":"# 🐘 postgres-audit-log\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Made with PostgreSQL](https://img.shields.io/badge/Made%20with-PostgreSQL-336791?logo=postgresql\u0026logoColor=white)](https://www.postgresql.org/) [![Powered by PL/pgSQL](https://img.shields.io/badge/Powered%20by-PL%2FpgSQL-336791)](https://www.postgresql.org/docs/current/plpgsql.html) [![PostgreSQL](https://img.shields.io/badge/PostgreSQL-17%2B-336791?logo=postgresql\u0026logoColor=white)](https://www.postgresql.org/) [![GitHub stars](https://img.shields.io/github/stars/richwrd/postgres-audit-log?style=social)](https://github.com/richwrd/postgres-audit-log/stargazers)\n\n\u003e Lightweight PostgreSQL DML audit solution with automatic trigger management and partition support\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/assets/banner.png\" width=100% alt=\"Banner\"\u003e\n    \u003cimg src=\"docs/assets/logging.png\" width=100% alt=\"Audit Logging\"\u003e\n\u003c/p\u003e\n\n**postgres-audit-log** is a simple and extensible audit solution for PostgreSQL databases, focused on tracking DML operations (INSERT, UPDATE, DELETE) with high flexibility and granular per-schema control.\n\nDesigned for developers, DBAs, and infrastructure teams who need reliable traceability of database changes without external dependencies.\n\n## 🎯 Why postgres-audit-log?\n\nUnlike heavyweight audit solutions that require external tools or complex setups, **postgres-audit-log** provides:\n\n- ✅ **Zero dependencies** - Pure PL/pgSQL implementation\n- ✅ **Minimal overhead** - Optimized trigger functions with partition support\n- ✅ **Easy deployment** - Single SQL file installation\n- ✅ **Flexible configuration** - Control auditing at schema and operation level\n- ✅ **Developer friendly** - JSONB format for easy querying and integration\n\n## ✨ Features\n\n| Feature                 | Description                                                                 |\n| ----------------------- | --------------------------------------------------------------------------- |\n| 📌 **Granular Control** | Enable/disable audit per schema and operation type (INSERT, UPDATE, DELETE) |\n| 🗂️ **Structured Logs**  | JSONB format with complete before/after data snapshots                      |\n| 🔄 **Auto Management**  | Dynamic trigger creation/removal via `audit.apply_rules()`                  |\n| 📊 **Partitioning**     | Monthly partitions with automatic management                                |\n| 🔒 **Data Integrity**   | Automatic validation and consistency checks                                 |\n| 🐘 **Pure PostgreSQL**  | No external extensions or dependencies required                             |\n| 🚀 **Production Ready** | Lightweight and battle-tested                                               |\n| 🔍 **Rich Metadata**    | Captures username, timestamp, transaction ID, and operation context         |\n\n## 🚀 Quick Start\n\n```bash\n# 1️⃣ Clone and install\ngit clone https://github.com/richwrd/postgres-audit-log.git\npsql -U your_user -d your_database -f ./src/setup.sql\n\n# 2️⃣ Create partitions\npsql -d your_database -c \"SELECT audit.auto_manage_partitions();\"\n\n# 3️⃣ Enable auditing\npsql -d your_database -c \"\n    INSERT INTO audit.log_control (schema_name, log_insert, log_update, log_delete)\n    VALUES ('public', TRUE, TRUE, TRUE);\n    SELECT audit.apply_rules();\"\n```\n\nSee the [Quick Start Guide](docs/quick-start.md) for detailed instructions.\n\n## 📚 Documentation\n\n- **[Quick Start](docs/quick-start.md)** - Get up and running in minutes\n- **[How It Works](docs/how-it-works.md)** - Understand the architecture and components\n- **[Usage Examples](docs/usage-examples.md)** - Common queries and advanced use cases\n- **[Comparison with pgAudit](docs/comparison-with-pgAudit.md)** - Differences and complementary features\n\n## 🛠️ Requirements\n\n- **PostgreSQL** 12+ (only tested on version 17 and above)\n- **Superuser privileges** (for trigger creation and schema management)\n\n## 📊 Structure Overview\n\n```\npostgres-audit-log/\n├── src/\n│   ├── setup.sql                   # Main installation file\n│   ├── 1-schema/\n│   │   ├── 1.1-tables.sql          # Creates audit tables\n│   │   └── 1.2-triggers.sql        # Trigger management\n│   └── 2-core/\n│       ├── 2.1-record_change.sql   # Core logging function\n│       ├── 2.2-apply_rules.sql     # Schema validation\n│       └── 2.3-partitions.sql      # Partition helpers\n└── docs/\n    ├── quick-start.md\n    ├── how-it-works.md\n    ├── usage-examples.md\n    └── comparison-with-pgAudit.md\n```\n\n## 🌟 Show your support\n\nGive a ⭐️ if this project helped you!\n\n## 🤝 Contributing\n\nContributions are welcome! Feel free to:\n\n1. Fork the project\n2. Create a feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## 📚 My Related Projects\n\n- [postgres-ha-cluster-lab](https://github.com/richwrd/postgres-ha-cluster-lab) - PostgreSQL High Availability Cluster with Patroni\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n\u003cdiv align=\"center\"\u003e\n\n## 👤 Author\n\n**Eduardo Richard** (richwrd)\n\n[![GitHub](https://img.shields.io/badge/GitHub-@richwrd-181717?logo=github\u0026logoColor=white)](https://github.com/richwrd)\n[![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0A66C2?logo=linkedin\u0026logoColor=white)](https://www.linkedin.com/in/eduardorichard/)\n[![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-support-FFDD00?logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/richwrd)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n**Built with ❤️ for the PostgreSQL community**\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichwrd%2Fpostgres-audit-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichwrd%2Fpostgres-audit-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichwrd%2Fpostgres-audit-log/lists"}