using Heimdall.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Heimdall.Infrastructure.Data.Configurations; public class UserRecoveryCodeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("user_recovery_codes"); builder.HasKey(r => r.Id); builder.Property(r => r.CodeHash) .HasMaxLength(64) .IsRequired() .IsUnicode(false); builder.Property(r => r.UserId) .IsRequired(); builder.Property(r => r.CreatedAt) .HasDefaultValueSql("NOW()"); builder.Property(r => r.UsedAt); // Indexes for lookup during login (single-use redemption) builder.HasIndex(r => new { r.UserId, r.CodeHash }) .IsUnique(); builder.HasIndex(r => r.UserId); } }