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

namespace Infrastructure.Persistence.Configurations.Crypto;

public sealed class CoinMarketConfiguration : IEntityTypeConfiguration<CoinMarket>
{
    public void Configure(EntityTypeBuilder<CoinMarket> builder)
    {
        builder.HasIndex(x => new { x.CoinID, x.Market }).IsUnique();
        builder.HasIndex(x => x.Market);

        builder.ToTable(nameof(CoinMarket), t => t.HasComment("코인-거래쌍 연결"));
        builder.HasKey(x => x.ID);
        builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
        builder.Property(x => x.CoinID).IsRequired().HasComment("코인 ID");
        builder.Property(x => x.Market).HasMaxLength(30).IsRequired().HasComment("거래쌍 (KRW-BTC 등)");
    }
}