implementing-database-audit-logging
Installation
SKILL.md
Database Audit Logger
Overview
Implement database audit logging to track all data modifications (INSERT, UPDATE, DELETE) with full before/after values, user identity, timestamps, and application context. This skill supports trigger-based auditing for PostgreSQL and MySQL, change data capture (CDC) patterns, and application-level audit logging.
Prerequisites
- Database credentials with CREATE TABLE, CREATE FUNCTION, and CREATE TRIGGER permissions
psqlormysqlCLI for executing audit setup DDL- Understanding of applicable compliance requirements (which tables, which operations, retention period)
- Estimated storage for audit logs: plan for 10-30% of the audited table's data volume per year
- Separate tablespace or storage volume for audit data to prevent audit growth from affecting application performance