Description
Add the AuditLog entity and AuditAction enum to the persistence layer, register DbSet on AppDbContext, and create the EF Core migration AddAuditLog.
New file src/UCK26.Api/Persistence/AuditLog.cs:
public enum AuditAction { Create, Update, Delete }
public class AuditLog
{
public int Id { get; set; }
public string EntityType { get; set; } = "WorkEntry";
public int EntityId { get; set; }
public AuditAction Action { get; set; }
public string PerformedBy { get; set; } = "";
public DateTime PerformedAt { get; set; }
public string? ChangedFields { get; set; } // JSON: [{field, oldValue, newValue}]
public string? EntryDate { get; set; } // denormalized WorkEntry.Date
public string? EntryType { get; set; } // denormalized WorkEntry.Type (work/holiday/doctor)
public int? WorksheetId { get; set; } // denormalized WorkEntry.WorksheetId
}
public record AuditChangedField(string Field, string? OldValue, string? NewValue);
Add to src/UCK26.Api/Persistence/AppDbContext.cs:
public DbSet<AuditLog> AuditLogs => Set<AuditLog>();
No FK from AuditLog to WorkEntry — intentional so logs survive entry deletion.
Run migration:
cd src/UCK26.Api
dotnet ef migrations add AddAuditLog
Reference: documents/work-entry-audit-log/work-entry-audit-log.handover.md
Acceptance Criteria
Description
Add the
AuditLogentity andAuditActionenum to the persistence layer, registerDbSetonAppDbContext, and create the EF Core migrationAddAuditLog.New file
src/UCK26.Api/Persistence/AuditLog.cs:Add to
src/UCK26.Api/Persistence/AppDbContext.cs:No FK from
AuditLogtoWorkEntry— intentional so logs survive entry deletion.Run migration:
cd src/UCK26.Api dotnet ef migrations add AddAuditLogReference:
documents/work-entry-audit-log/work-entry-audit-log.handover.mdAcceptance Criteria
dotnet ef database updateand confirm it applies without errors. Verify via EF model snapshot thatAuditLogstable has all expected columns (EntryTypeincluded) and no FK toWorkEntry. No separate test file needed — downstream integration tests inTestWebApplicationFactoryconfirm the table is queryable; those must pass.AuditLogto the entities list and note there is no FK toWorkEntryby design.Persistence/, addAuditLog.cswith a short comment.AuditLogentity andAuditActionenum exist insrc/UCK26.Api/Persistence/AuditLog.csEntryTypefield present onAuditLog(nullable string, stores"work"/"holiday"/"doctor")AppDbContext.AuditLogsDbSet registeredAddAuditLogcreated and applies cleanly (dotnet ef database update)AuditLogtoWorkEntry