63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
using ErsatzTV.Core.Domain;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace ErsatzTV.Infrastructure.Data.Configurations;
|
|
|
|
public class ChannelTemplateConfiguration : IEntityTypeConfiguration<ChannelTemplate>
|
|
{
|
|
public void Configure(EntityTypeBuilder<ChannelTemplate> builder)
|
|
{
|
|
builder.ToTable("ChannelTemplate");
|
|
|
|
builder.HasIndex(t => t.Name)
|
|
.IsUnique();
|
|
|
|
builder.Property(t => t.Name)
|
|
.HasMaxLength(50)
|
|
.HasColumnType("varchar(50)")
|
|
.IsRequired();
|
|
|
|
builder.Property(t => t.Description)
|
|
.HasMaxLength(500)
|
|
.HasColumnType("varchar(500)")
|
|
.HasDefaultValue(string.Empty)
|
|
.IsRequired();
|
|
|
|
builder.HasOne(t => t.FFmpegProfile)
|
|
.WithMany()
|
|
.HasForeignKey(t => t.FFmpegProfileId)
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
builder.HasOne(t => t.Watermark)
|
|
.WithMany()
|
|
.HasForeignKey(t => t.WatermarkId)
|
|
.OnDelete(DeleteBehavior.SetNull)
|
|
.IsRequired(false);
|
|
|
|
builder.HasOne(t => t.FallbackFiller)
|
|
.WithMany()
|
|
.HasForeignKey(t => t.FallbackFillerId)
|
|
.OnDelete(DeleteBehavior.SetNull)
|
|
.IsRequired(false);
|
|
|
|
builder.HasOne(t => t.PreRollFiller)
|
|
.WithMany()
|
|
.HasForeignKey(t => t.PreRollFillerId)
|
|
.OnDelete(DeleteBehavior.SetNull)
|
|
.IsRequired(false);
|
|
|
|
builder.HasOne(t => t.MidRollFiller)
|
|
.WithMany()
|
|
.HasForeignKey(t => t.MidRollFillerId)
|
|
.OnDelete(DeleteBehavior.SetNull)
|
|
.IsRequired(false);
|
|
|
|
builder.HasOne(t => t.PostRollFiller)
|
|
.WithMany()
|
|
.HasForeignKey(t => t.PostRollFillerId)
|
|
.OnDelete(DeleteBehavior.SetNull)
|
|
.IsRequired(false);
|
|
}
|
|
}
|