using Domain.Entities.Members.Logs;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Infrastructure.Persistence.Configurations.Members.Logs;

public sealed class MemberIntroChangeLogConfiguration : IEntityTypeConfiguration<MemberIntroChangeLog>
{
    public void Configure(EntityTypeBuilder<MemberIntroChangeLog> builder)
    {
        builder.HasOne(x => x.Member).WithMany().HasForeignKey(x => x.MemberID).OnDelete(DeleteBehavior.Cascade);
        builder.HasIndex(x => x.MemberID);

        builder.ToTable(nameof(MemberIntroChangeLog), x => x.HasComment("자기소개 변경 내역"));
        builder.HasKey(x => x.ID);
        builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
        builder.Property(x => x.MemberID).IsRequired().HasComment("회원 ID");
        builder.Property(x => x.BeforeIntro).HasMaxLength(3000).HasComment("이전 자기소개");
        builder.Property(x => x.AfterIntro).HasMaxLength(3000).HasComment("바꾼 자기소개");
        builder.Property(x => x.Referer).HasComment("이전 페이지 주소");
        builder.Property(x => x.IpAddress).HasMaxLength(15).HasComment("IP Address");
        builder.Property(x => x.UserAgent).HasMaxLength(512).HasComment("User Agent");
        builder.Property(x => x.CreatedAt).IsRequired().HasComment("등록 일시");
    }
}