feat: audit_event table, Audit log module and audit Pub/Sub topic
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
01603e9ece
commit
b9912478e0
6 files changed
+67
-1
No files matched your search
@@ -0,0 +1,25 @@
|
||||
-- Co-Lite change add-admin-audit-log: the admin audit trail.
|
||||
-- Target: `service-log`.`audit_event`. Additive only. Run once, after the release package.
|
||||
-- DDL: run with a user that may create tables, not the services' user.
|
||||
-- Written by services-log from the audit-event-topic Pub/Sub messages that mobile-api publishes.
|
||||
USE `service-log`;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `audit_event` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`company_id` bigint NULL,
|
||||
`occurred_at` datetime(6) NOT NULL,
|
||||
`actor` varchar(191) NOT NULL,
|
||||
`module` varchar(64) NULL,
|
||||
`action` varchar(128) NOT NULL,
|
||||
`http_method` varchar(16) NULL,
|
||||
`path_template` varchar(255) NULL,
|
||||
`target_id` varchar(128) NULL,
|
||||
`outcome` varchar(16) NOT NULL COMMENT 'SUCCESS | FAILURE',
|
||||
`http_status` int NULL,
|
||||
`client_ip` varchar(64) NULL,
|
||||
`changes` text NULL COMMENT 'JSON: allow-listed before/after, or changed field names',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_audit_event_occurred_at` (`occurred_at`),
|
||||
KEY `idx_audit_event_actor` (`actor`, `occurred_at`),
|
||||
KEY `idx_audit_event_module_action` (`module`, `action`, `occurred_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
Reference in new issue
Block a user