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).
Tasks
GET /log(List all audit logs)GET /log/{id}(Get details of a specific log entry)AuditLogmodel (see below)user_id,table_name, or date range)Creating the
AuditLogModelThis model tracks changes across the system for debugging, security, and future rollback functionality.
Expected Fields
iduser_idusers.id(who made the change)table_namerecord_idcolumn_nameold_valuenew_valuechanged_atCURRENT_TIMESTAMPNotes
user_idtracks who made the change.table_nameandcolumn_nametrack what was changed.record_idallows logs to be linked to specific items, boxes, locations, etc.old_valueandnew_valueallow comparison of before and after states.user_id(to see changes by a specific user).table_name(to track specific entities likeitemsorlocations).Next Steps