--- 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.