From 05bf8788b36e9d48ca9a60b026aa51b54b627499 Mon Sep 17 00:00:00 2001 From: Hermes AI Bot Date: Sun, 19 Jul 2026 16:00:38 +0000 Subject: [PATCH] tip #38: Audit-Log: who changed what --- TIPS.md | 1 + ...19-038-admin-audit-log-who-changed-what.md | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tips/2026-07-19-038-admin-audit-log-who-changed-what.md diff --git a/TIPS.md b/TIPS.md index d732b60..1c9bd3e 100644 --- a/TIPS.md +++ b/TIPS.md @@ -30,3 +30,4 @@ Going forward, new tips are pushed automatically by the `mc_survival_tips.py` cr - [Tip #37](tips/2026-07-17-037-search-fuzzy-search-for-items-recipes.md) (2026-07-17) — **search**: Fuzzy-Search for items & recipes - [Tip #37](tips/2026-07-17-037-crafting-ux-missing-item-highlight-in-recipe.md) (2026-07-17) — **crafting-ux**: Missing-item highlight in recipe - [Tip #37](tips/2026-07-18-037-search-fuzzy-search-for-items-recipes.md) (2026-07-18) — **search**: Fuzzy-Search for items & recipes +- [Tip #38](tips/2026-07-19-038-admin-audit-log-who-changed-what.md) (2026-07-19) — **admin**: Audit-Log: who changed what diff --git a/tips/2026-07-19-038-admin-audit-log-who-changed-what.md b/tips/2026-07-19-038-admin-audit-log-who-changed-what.md new file mode 100644 index 0000000..f616e71 --- /dev/null +++ b/tips/2026-07-19-038-admin-audit-log-who-changed-what.md @@ -0,0 +1,22 @@ +--- +tip_number: 38 +date: 2026-07-19 +category: admin +status: pending +--- + +# Tip #38 — Audit-Log: who changed what + +**Date:** 2026-07-19 +**Category:** admin +**Source:** MC-Survival Wiki Daily Tip (cron @ 18:00 MESZ) + +## Audit-Log: who changed what + +An audit log is a dedicated Prisma model that records every editor mutation — who did what, on which entity, with the before/after snapshot and a timestamp. It solves the inevitable 'who broke the diamond-sword recipe' question that appears as soon as there is more than one editor. The signal is operational: we are about to invite moderators, and without an audit trail every content dispute becomes a he-said-she-said. A withAudit(fn, action) helper that wraps existing mutations keeps the call-site change to one line, which matters because a feature that requires editing 30 endpoints will not get merged. + +## Implementation tips + +1. New Prisma model: AuditLog { id, userId, action, entityType, entityId, before, after, createdAt }. +2. Wrap all editor mutations in functions.ts with a small withAudit(fn, action) helper — one line per call site. +3. Add a /admin/audit route with filter by user, entity, date range.