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

namespace UniVerse.Infrastructure.Data.Configurations;

public class AchievementConfiguration : IEntityTypeConfiguration<Achievement>
{
    public void Configure(EntityTypeBuilder<Achievement> builder)
    {
        builder.ToTable("achievements");

        builder.HasKey(a => a.Id);
        builder.Property(a => a.Id).HasColumnName("id");
        builder.Property(a => a.Name).HasColumnName("name").HasMaxLength(255).IsRequired();
        builder.Property(a => a.Description).HasColumnName("description");
        builder.Property(a => a.IconUrl).HasColumnName("icon_url").HasMaxLength(500);
        builder.Property(a => a.XpReward).HasColumnName("xp_reward").HasDefaultValue(0);
        builder.Property(a => a.CoinReward).HasColumnName("coin_reward").HasDefaultValue(0);
        builder.Property(a => a.Condition).HasColumnName("condition");
        builder.Property(a => a.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
    }
}
