feat(audit): surface field-level before/after content in change history (PMS-204) #156
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-204-history-content"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Backend half of PMS-204: the change-history feed now carries the actual before/after content of each edit, not just the field names.
Changes
EntityHistoryEntry(theGET /api/v1/audit-log/entity/{type}/{id}response) gains achangesarray of{ field, old, new }, computed from theaudit_logbefore/after JSON snapshots by a new sharedfield_changeshelper (noise columns excluded, sorted for a stable order).changed_fieldsis now derived from it, so the existing summary line is unchanged.asset_audit_logtable, which previously stored no diff for updates.update_assetnow snapshots the row before and after withto_jsonband persists the same{field, old, new}diff into the row'schangescolumn, so the asset detail page can show content too.Tests
ticket_history_records_description_edit: now also asserts the entry'schangescarries the descriptionold("Paper stuck in tray 2.") andnew("Paper stuck in tray 2 and toner low.").asset_crud_and_filtering: asserts the status edit's audit row carries{field: status, old: active, new: in_repair}.Pairs with a mokosh-apps PR that renders the before to after content on the ticket, project/task, and asset detail pages.
🤖 Generated with Claude Code
The per-record history showed who/when and the changed field names but not the actual content of the edit. Add a `changes` array of {field, old, new} to EntityHistoryEntry, computed from the audit_log before/after snapshots by a shared `field_changes` helper (noise columns still excluded, sorted for stable order). `changed_fields` is now derived from it. For assets (which use the separate asset_audit_log table), update_asset now snapshots the row before and after with to_jsonb and persists the same diff into the row's `changes` column, so the asset detail page can show content too. Tests assert tickets carry the description old/new and assets carry the status old/new. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>