40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using Heimdall.Domain.Entities;
|
|||
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||
|
|
|
||
|
|
namespace Heimdall.Infrastructure.Data.Configurations;
|
||
|
|
|
||
|
|
public class PersonConfiguration : IEntityTypeConfiguration<Person>
|
||
|
|
{
|
||
|
|
public void Configure(EntityTypeBuilder<Person> builder)
|
||
|
|
{
|
||
|
|
builder.ToTable("persons");
|
||
|
|
|
||
|
|
builder.HasKey(p => p.Id);
|
||
|
|
|
||
|
|
builder.Property(p => p.DisplayName)
|
||
|
|
.HasMaxLength(200)
|
||
|
|
.IsRequired();
|
||
|
|
|
||
|
|
builder.Property(p => p.Notes)
|
||
|
|
.HasMaxLength(2000);
|
||
|
|
|
||
|
|
builder.Property(p => p.PhotoUrl)
|
||
|
|
.HasMaxLength(2000)
|
||
|
|
.IsUnicode(false);
|
||
|
|
|
||
|
|
builder.Property(p => p.Category)
|
||
|
|
.HasMaxLength(50)
|
||
|
|
.IsUnicode(false);
|
||
|
|
|
||
|
|
builder.HasIndex(p => p.DisplayName);
|
||
|
|
builder.HasIndex(p => p.Category);
|
||
|
|
builder.HasIndex(p => p.IsWatchlisted);
|
||
|
|
|
||
|
|
// OwnsMany for KnownFace (stored as JSONB or separate table)
|
||
|
|
builder.HasMany(p => p.Faces)
|
||
|
|
.WithOne(f => f.Person)
|
||
|
|
.HasForeignKey(f => f.PersonId)
|
||
|
|
.OnDelete(DeleteBehavior.Cascade);
|
||
|
|
}
|
||
|
|
}
|