Added configurations for entity builders. Also added VoiceWorkLocaalization entity.

This commit is contained in:
2025-08-27 00:16:10 -04:00
parent d2201d6f9b
commit 22b8513e34
16 changed files with 299 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using JSMR.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace JSMR.Infrastructure.Data.Configuration;
public sealed class VoiceWorkConfiguration : IEntityTypeConfiguration<VoiceWork>
{
public void Configure(EntityTypeBuilder<VoiceWork> builder)
{
builder.ToTable("voice_works");
builder.HasKey(x => x.VoiceWorkId);
builder.Property(x => x.ProductId)
.IsRequired()
.HasMaxLength(16);
builder.Property(x => x.OriginalProductId)
.HasMaxLength(16);
builder.Property(x => x.ProductName)
.IsRequired()
.HasMaxLength(256);
builder.Property(x => x.Description)
.HasMaxLength(512);
// Relationships
builder.HasOne(x => x.Circle)
.WithMany(c => c.VoiceWorks)
.HasForeignKey(x => x.CircleId)
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(x => x.Series)
.WithMany(s => s.VoiceWorks)
.HasForeignKey(x => x.SeriesId)
.OnDelete(DeleteBehavior.SetNull);
// Indexes for common filters/sorts
builder.HasIndex(x => x.ProductId).IsUnique();
builder.HasIndex(x => x.CircleId);
builder.HasIndex(x => x.SalesDate);
builder.HasIndex(x => x.ExpectedDate);
builder.HasIndex(x => x.Favorite);
builder.HasIndex(x => x.IsValid);
builder.HasIndex(x => x.SubtitleLanguage);
builder.HasIndex(x => x.AIGeneration);
builder.HasIndex(x => x.Downloads);
builder.HasIndex(x => x.WishlistCount);
}
}