using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Nuuru.Server.Data.EntityConfigurations { public class WatchConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasKey(w => w.Id); // Cascade delete: when user is deleted, remove their watches builder.HasOne(w => w.User) .WithMany() .HasForeignKey(w => w.UserId) .OnDelete(DeleteBehavior.Cascade); // Unique constraint: one watch per user per target builder.HasIndex(w => new { w.UserId, w.TargetType, w.TargetId }) .IsUnique(); // Index for querying watchers of a target builder.HasIndex(w => new { w.TargetType, w.TargetId }); } } }