feat: add audit logging framework with immutable append-only log
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
19
src/main/resources/db/migration/V004__create_audit_log.sql
Normal file
19
src/main/resources/db/migration/V004__create_audit_log.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE audit_log (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
actor_id UUID,
|
||||
actor_email VARCHAR(255),
|
||||
tenant_id UUID,
|
||||
action VARCHAR(100) NOT NULL,
|
||||
resource VARCHAR(500),
|
||||
environment VARCHAR(50),
|
||||
source_ip VARCHAR(45),
|
||||
result VARCHAR(20) NOT NULL DEFAULT 'SUCCESS',
|
||||
metadata JSONB,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_audit_log_tenant ON audit_log (tenant_id, created_at DESC);
|
||||
CREATE INDEX idx_audit_log_actor ON audit_log (actor_id, created_at DESC);
|
||||
CREATE INDEX idx_audit_log_action ON audit_log (action, created_at DESC);
|
||||
|
||||
COMMENT ON TABLE audit_log IS 'Immutable audit trail. No UPDATE or DELETE allowed.';
|
||||
Reference in New Issue
Block a user