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

namespace Infrastructure.Persistence.Configurations.Crypto;

public sealed class CoinCategoryConfiguration : IEntityTypeConfiguration<CoinCategory>
{
    public void Configure(EntityTypeBuilder<CoinCategory> builder)
    {
        builder.HasIndex(x => x.Code).IsUnique();
        builder.HasIndex(x => x.Order);
        builder.HasIndex(x => x.IsActive);

        builder.ToTable(nameof(CoinCategory), t => t.HasComment("코인 카테고리"));
        builder.HasKey(x => x.ID);
        builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
        builder.Property(x => x.Code).HasMaxLength(30).IsRequired().HasComment("카테고리 코드");
        builder.Property(x => x.Name).HasMaxLength(100).IsRequired().HasComment("카테고리 이름");
        builder.Property(x => x.Order).IsRequired().HasComment("순서");
        builder.Property(x => x.IsActive).IsRequired().HasComment("사용 여부");
        builder.Property(x => x.UpdatedAt).HasComment("수정 일시");
        builder.Property(x => x.CreatedAt).IsRequired().HasComment("등록 일시");
    }
}