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.
This commit is contained in:
Arnaud Dartois committed 2026-07-17 19:31:11 +00:00
1 parent c36978d5a1
commit b04d8a72c2
8 files changed
+52 -26

No files matched your search

@@ -14,32 +14,40 @@ public class AgentConfiguration : IEntityTypeConfiguration<Agent>
builder.Property(a => a.Name)
.HasMaxLength(200)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(a => a.Hostname)
.HasMaxLength(255)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(a => a.Version)
.HasMaxLength(50);
.HasMaxLength(50)
.IsUnicode(false);
builder.Property(a => a.Status)
.HasConversion<string>()
.HasMaxLength(20)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(a => a.PublicIp)
.HasMaxLength(45);
.HasMaxLength(45)
.IsUnicode(false);
builder.Property(a => a.ApiKeyHash)
.HasMaxLength(128);
.HasMaxLength(128)
.IsUnicode(false);
builder.Property(a => a.ApiKeyPrefix)
.HasMaxLength(8);
.HasMaxLength(8)
.IsUnicode(false);
builder.Property(a => a.GpuType)
.HasConversion<string>()
.HasMaxLength(20);
.HasMaxLength(20)
.IsUnicode(false);
builder.Property(a => a.CreatedAt)
.HasDefaultValueSql("NOW()");
@@ -14,11 +14,13 @@ public class ApiKeyConfiguration : IEntityTypeConfiguration<ApiKey>
builder.Property(k => k.KeyHash)
.HasMaxLength(128)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(k => k.KeyPrefix)
.HasMaxLength(8)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(k => k.CreatedAt)
.HasDefaultValueSql("NOW()");
@@ -14,17 +14,21 @@ public class AuditLogConfiguration : IEntityTypeConfiguration<AuditLog>
builder.Property(al => al.Action)
.HasMaxLength(100)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(al => al.ResourceType)
.HasMaxLength(100)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(al => al.ResourceId)
.HasMaxLength(100);
.HasMaxLength(100)
.IsUnicode(false);
builder.Property(al => al.IpAddress)
.HasMaxLength(45);
.HasMaxLength(45)
.IsUnicode(false);
builder.Property(al => al.Timestamp)
.HasDefaultValueSql("NOW()");
@@ -14,7 +14,8 @@ public class CameraConfiguration : IEntityTypeConfiguration<Camera>
builder.Property(c => c.Name)
.HasMaxLength(200)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(c => c.Manufacturer)
.HasMaxLength(100);
@@ -23,12 +24,14 @@ public class CameraConfiguration : IEntityTypeConfiguration<Camera>
.HasMaxLength(100);
builder.Property(c => c.RtspUrl)
.HasMaxLength(1000);
.HasMaxLength(1000)
.IsUnicode(false);
builder.Property(c => c.Status)
.HasConversion<string>()
.HasMaxLength(20)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(c => c.CreatedAt)
.HasDefaultValueSql("NOW()");
@@ -14,17 +14,21 @@ public class CameraCredentialsConfiguration : IEntityTypeConfiguration<CameraCre
builder.Property(c => c.OnvifUsername)
.HasMaxLength(100)
.HasDefaultValue("admin");
.HasDefaultValue("admin")
.IsUnicode(false);
builder.Property(c => c.OnvifPassword)
.HasMaxLength(500)
.IsRequired();
.IsRequired()
.IsUnicode(false);
builder.Property(c => c.RtspUsername)
.HasMaxLength(100);
.HasMaxLength(100)
.IsUnicode(false);
builder.Property(c => c.RtspPassword)
.HasMaxLength(500);
.HasMaxLength(500)
.IsUnicode(false);
builder.Property(c => c.CreatedAt)
.HasDefaultValueSql("NOW()");
@@ -14,7 +14,8 @@ public class CameraDetectionProfileConfiguration : IEntityTypeConfiguration<Came
builder.Property(p => p.YoloModel)
.HasMaxLength(50)
.HasDefaultValue("yolov8n");
.HasDefaultValue("yolov8n")
.IsUnicode(false);
builder.Property(p => p.MinConfidence)
.HasDefaultValue(0.4);
@@ -17,11 +17,13 @@ public class AppUserConfiguration : IEntityTypeConfiguration<AppUser>
builder.Property(u => u.Theme)
.HasMaxLength(20)
.HasDefaultValue("Auto");
.HasDefaultValue("Auto")
.IsUnicode(false);
builder.Property(u => u.Language)
.HasMaxLength(10)
.HasDefaultValue("fr");
.HasDefaultValue("fr")
.IsUnicode(false);
builder.Property(u => u.CreatedAt)
.HasDefaultValueSql("NOW()");
@@ -22,10 +22,12 @@ public class SiteConfiguration : IEntityTypeConfiguration<Site>
builder.Property(s => s.Timezone)
.HasMaxLength(100)
.IsRequired()
.HasDefaultValue("UTC");
.HasDefaultValue("UTC")
.IsUnicode(false);
builder.Property(s => s.RegistrationTokenHash)
.HasMaxLength(128);
.HasMaxLength(128)
.IsUnicode(false);
builder.Property(s => s.CreatedAt)
.HasDefaultValueSql("NOW()");