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

namespace Infrastructure.Persistence.Configurations.Members.Logs;

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

        builder.ToTable(nameof(MemberExpLog), 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.Reason).HasMaxLength(200).IsRequired().HasComment("사유");
        builder.Property(x => x.Amount).IsRequired().HasComment("변동량");
        builder.Property(x => x.Balance).IsRequired().HasComment("잔액");
        builder.Property(x => x.CreatedAt).IsRequired().HasComment("기록 일시");
    }
}