1.1 KiB
1.1 KiB
tip_number, date, category, status
| tip_number | date | category | status |
|---|---|---|---|
| 38 | 2026-07-19 | admin | 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
- New Prisma model: AuditLog { id, userId, action, entityType, entityId, before, after, createdAt }.
- Wrap all editor mutations in functions.ts with a small withAudit(fn, action) helper — one line per call site.
- Add a /admin/audit route with filter by user, entity, date range.