forked from BRETT/BRETT
New audit_log table records actor, action, target and a JSON snapshot of the details, so entries stay readable after the target is deleted; the actor is set to NULL when the user is removed. logAudit() is called from upload delete (single and bulk), comment delete, tag removal, role create/delete, role permission changes, role assign/revoke and MOTD updates. Logging failures only warn and never fail the action itself. The admin page gets an audit card behind the new audit.view permission with action filter, click-to-filter by user, readable summaries per action and server-side pagination. Action catalog lives in shared/utils/audit.ts, labels under admin.auditActions (de/en). Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 lines
574 B
SQL
13 lines
574 B
SQL
CREATE TABLE `audit_log` (
|
|
`id` bigint unsigned AUTO_INCREMENT NOT NULL,
|
|
`user_id` bigint unsigned,
|
|
`action` varchar(50) NOT NULL,
|
|
`target_type` varchar(32),
|
|
`target_id` varchar(64),
|
|
`details` json,
|
|
`created_at` timestamp NOT NULL DEFAULT (now()),
|
|
CONSTRAINT `audit_log_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE `audit_log` ADD CONSTRAINT `audit_log_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX `audit_log_action_idx` ON `audit_log` (`action`); |