using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SolutionErp.Domain.Notifications;

namespace SolutionErp.Infrastructure.Persistence.Configurations;

public class NotificationConfiguration : IEntityTypeConfiguration<Notification>
{
    public void Configure(EntityTypeBuilder<Notification> e)
    {
        e.ToTable("Notifications");
        e.HasKey(x => x.Id);
        e.Property(x => x.Type).HasConversion<int>();
        e.Property(x => x.Title).HasMaxLength(300).IsRequired();
        e.Property(x => x.Description).HasMaxLength(1000);
        e.Property(x => x.Href).HasMaxLength(500);

        e.HasIndex(x => new { x.UserId, x.ReadAt });
        e.HasIndex(x => x.CreatedAt);
    }
}
