using Heimdall.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using System.Text.Json; namespace Heimdall.Infrastructure.Data.Configurations; public class KnownFaceConfiguration : IEntityTypeConfiguration { private static readonly JsonSerializerOptions JsonOptions = new(); public void Configure(EntityTypeBuilder builder) { builder.ToTable("known_faces"); builder.HasKey(f => f.Id); builder.Property(f => f.ThumbnailUrl) .HasMaxLength(2000) .IsUnicode(false); builder.Property(f => f.SourceEventId) .HasMaxLength(100) .IsUnicode(false); // Store float[] as JSONB builder.Property(f => f.Embedding) .HasColumnType("jsonb") .HasConversion( v => JsonSerializer.Serialize(v, JsonOptions), v => JsonSerializer.Deserialize(v, JsonOptions) ?? Array.Empty()); builder.HasIndex(f => f.PersonId); } }