using Heimdall.Domain.Entities; using Heimdall.Domain.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Heimdall.Infrastructure.Data.Configurations; public class AgentLogEntryConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("agent_log_entries"); builder.HasKey(e => e.Id); builder.Property(e => e.TimestampUtc) .IsRequired(); builder.Property(e => e.Level) .HasConversion() .HasMaxLength(20) .IsRequired() .IsUnicode(false); builder.Property(e => e.Message) .HasMaxLength(2000) .IsRequired(); builder.Property(e => e.Exception) .HasMaxLength(4000); builder.Property(e => e.Source) .HasMaxLength(200) .IsUnicode(false); // Composite index: reads per agent (logs page) + purge by age. builder.HasIndex(e => new { e.AgentId, e.TimestampUtc }); builder.HasOne(e => e.Agent) .WithMany() .HasForeignKey(e => e.AgentId) .OnDelete(DeleteBehavior.Cascade); } }