feat(domain): entités métier Vehicle/Recording/LicensePlate/StoragePolicy + relations Event→Vehicle/Recording, Camera→StoragePolicy (Fixes #6)

This commit is contained in:
Arnaud Dartois committed 2026-08-11 21:42:46 +02:00
1 parent 33a08f5ea0
commit 29ff980db5
19 files changed
+3658

No files matched your search

@@ -0,0 +1,57 @@
using Heimdall.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Heimdall.Infrastructure.Data.Configurations;
public class RecordingConfiguration : IEntityTypeConfiguration<Recording>
{
public void Configure(EntityTypeBuilder<Recording> builder)
{
builder.ToTable("recordings");
builder.HasKey(r => r.Id);
builder.Property(r => r.Timestamp)
.IsRequired();
builder.Property(r => r.DurationSeconds)
.HasDefaultValue(0.0);
builder.Property(r => r.StoragePath)
.HasMaxLength(2000)
.IsRequired()
.IsUnicode(false);
builder.Property(r => r.SizeBytes)
.IsRequired();
builder.Property(r => r.StorageProvider)
.HasConversion<string>()
.HasMaxLength(20)
.IsRequired()
.IsUnicode(false);
builder.Property(r => r.CreatedAt)
.HasDefaultValueSql("NOW()");
builder.Property(r => r.UpdatedAt)
.HasDefaultValueSql("NOW()");
// Indexes (spec 2.3)
builder.HasIndex(r => new { r.CameraId, r.Timestamp }); // timeline per camera
builder.HasIndex(r => r.StoragePath).IsUnique(); // storage dedup
builder.HasIndex(r => r.StoragePolicyId);
// Relationships
builder.HasOne(r => r.Camera)
.WithMany()
.HasForeignKey(r => r.CameraId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasOne(r => r.StoragePolicy)
.WithMany()
.HasForeignKey(r => r.StoragePolicyId)
.OnDelete(DeleteBehavior.SetNull);
}
}