using Domain.Entities.Donations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Infrastructure.Persistence.Configurations.Donations;

public class CrewWidgetConfigConfiguration : IEntityTypeConfiguration<CrewWidgetConfig>
{
    public void Configure(EntityTypeBuilder<CrewWidgetConfig> builder)
    {
        builder.ToTable(nameof(CrewWidgetConfig), x => x.HasComment("크루 위젯 설정"));
        builder.HasKey(x => x.ID);

        builder.HasOne(x => x.Channel).WithMany().HasForeignKey(x => x.ChannelID).OnDelete(DeleteBehavior.Cascade);
        builder.HasOne(x => x.Member).WithMany().HasForeignKey(x => x.MemberID).OnDelete(DeleteBehavior.NoAction);

        builder.HasIndex(x => x.ChannelID);

        builder.Property(x => x.Title).HasMaxLength(300).IsRequired();
        builder.Property(x => x.BgColor).HasMaxLength(7);
        builder.Property(x => x.TitleFontColor).HasMaxLength(7);
        builder.Property(x => x.Rank1FontColor).HasMaxLength(7);
        builder.Property(x => x.Rank2FontColor).HasMaxLength(7);
        builder.Property(x => x.Rank3FontColor).HasMaxLength(7);
        builder.Property(x => x.RowFontColor).HasMaxLength(7);
    }
}