All CRUD operations need to be logged (audit trail) #5

Open
opened 2026-06-16 08:42:59 +00:00 by martin · 0 comments
Owner

Story

As an admin, I want every create/update/delete operation on items and bins to be logged so I can audit who changed what and when.

Current state

Items already record created_by_id / updated_by_id + timestamps in the DB row. That gives us the last editor but loses history on multiple edits.

What we need

A proper audit log table that records:

Field Type Description
id int PK
table_name str 'items' or 'storage_bins'
record_id int FK to the affected row
action enum CREATE / UPDATE / DELETE
changed_by_id int FK to users
diff JSON {field: [old, new]} for updates
timestamp datetime when it happened

Acceptance criteria

  • Audit log written on every successful CREATE, UPDATE, DELETE
  • GET /admin/audit-log endpoint (admin only) with filtering by table, action, user, date range
  • Log is append-only (no DELETE or UPDATE on audit rows)

Notes

Ported from v1 issue #3.

## Story As an admin, I want every create/update/delete operation on items and bins to be logged so I can audit who changed what and when. ## Current state Items already record `created_by_id` / `updated_by_id` + timestamps in the DB row. That gives us the last editor but loses history on multiple edits. ## What we need A proper **audit log table** that records: | Field | Type | Description | |-------|------|-------------| | id | int | PK | | table_name | str | 'items' or 'storage_bins' | | record_id | int | FK to the affected row | | action | enum | CREATE / UPDATE / DELETE | | changed_by_id | int | FK to users | | diff | JSON | `{field: [old, new]}` for updates | | timestamp | datetime | when it happened | ## Acceptance criteria - [ ] Audit log written on every successful CREATE, UPDATE, DELETE - [ ] `GET /admin/audit-log` endpoint (admin only) with filtering by table, action, user, date range - [ ] Log is append-only (no DELETE or UPDATE on audit rows) ## Notes Ported from v1 issue #3.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: martin/flipventory_v2#5