Files
Heimdall/src/Heimdall.Infrastructure/Data/Configurations/AuditLogConfiguration.cs
T
Arnaud Dartois b04d8a72c2 perf(db): add IsUnicode(false) on ASCII-only code/identifier columns
Added IsUnicode(false) to hostname, version, status, IP, hash,
prefix, key, URL, timezone, theme, language, YOLO model name,
and enum-based string columns. These columns only contain ASCII
data — disabling Unicode improves PostgreSQL index efficiency
and reduces storage.

Excluded natural text columns (Address, DisplayName, Site.Name)
that may contain Unicode characters like accented letters.
2026-07-17 19:31:11 +00:00

52 lines
1.4 KiB
C#

using Heimdall.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Heimdall.Infrastructure.Data.Configurations;
public class AuditLogConfiguration : IEntityTypeConfiguration<AuditLog>
{
public void Configure(EntityTypeBuilder<AuditLog> builder)
{
builder.ToTable("audit_logs");
builder.HasKey(al => al.Id);
builder.Property(al => al.Action)
.HasMaxLength(100)
.IsRequired()
.IsUnicode(false);
builder.Property(al => al.ResourceType)
.HasMaxLength(100)
.IsRequired()
.IsUnicode(false);
builder.Property(al => al.ResourceId)
.HasMaxLength(100)
.IsUnicode(false);
builder.Property(al => al.IpAddress)
.HasMaxLength(45)
.IsUnicode(false);
builder.Property(al => al.Timestamp)
.HasDefaultValueSql("NOW()");
// Relationships
builder.HasOne(al => al.User)
.WithMany()
.HasForeignKey(al => al.UserId)
.OnDelete(DeleteBehavior.SetNull);
// Indexes
builder.HasIndex(al => al.Timestamp)
.IsDescending();
builder.HasIndex(al => new { al.ResourceType, al.ResourceId, al.Timestamp })
.IsDescending(false, false, true);
builder.HasIndex(al => al.UserId);
}
}