Skip to content

Implement /log Endpoint #50

Description

@foxleigh81

Tasks

  • Create the following endpoints:
    • GET /log (List all audit logs)
    • GET /log/{id} (Get details of a specific log entry)
  • Create the AuditLog model (see below)
  • Implement filtering options (e.g., by user_id, table_name, or date range)

Creating the AuditLog Model

This model tracks changes across the system for debugging, security, and future rollback functionality.

Expected Fields

Field Type Required Notes
id UUID Primary key
user_id UUID Foreign key referencing users.id (who made the change)
table_name String The table where the change occurred
record_id UUID The ID of the affected record
column_name String The specific column that was changed
old_value Text The previous value (nullable)
new_value Text The new value (nullable)
changed_at Timestamp Defaults to CURRENT_TIMESTAMP

Notes

  • user_id tracks who made the change.
  • table_name and column_name track what was changed.
  • record_id allows logs to be linked to specific items, boxes, locations, etc.
  • old_value and new_value allow comparison of before and after states.
  • Filtering should be supported:
    • By user_id (to see changes by a specific user).
    • By table_name (to track specific entities like items or locations).
    • By date range (e.g., last 30 days of changes).

Next Steps

  • Implement API pagination for large datasets.
  • Consider role-based access (e.g., only admins can see logs).
  • Ensure appropriate error handling (e.g., invalid filters).

Metadata

Metadata

Assignees

No one assigned

    Labels

    0-BACKENDRelates to the 'backend' project
    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions