| | | 1 | | using ArturRios.Heimdall.Domain.Entities; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 4 | | |
| | | 5 | | namespace ArturRios.Heimdall.Data.EntityMaps; |
| | | 6 | | |
| | | 7 | | internal static class AttemptNoticeBudgetDbMap |
| | | 8 | | { |
| | | 9 | | public static void Configure(this EntityTypeBuilder<AttemptNoticeBudget> budget) |
| | | 10 | | { |
| | 3 | 11 | | budget.ToTable("attempt_notice_budget"); |
| | | 12 | | |
| | | 13 | | // Internal bigint Id, never exposed (NFR-15): the row is reached by its address digest only. |
| | 3 | 14 | | budget.HasKey(x => x.Id); |
| | | 15 | | |
| | | 16 | | // One row per address. The charge's INSERT … ON CONFLICT (address_hash) relies on this index. |
| | 3 | 17 | | budget.Property(x => x.AddressHash).IsRequired().HasMaxLength(64); |
| | 3 | 18 | | budget.HasIndex(x => x.AddressHash).IsUnique(); |
| | | 19 | | |
| | 3 | 20 | | budget.Property(x => x.NoticesSent).IsRequired(); |
| | 3 | 21 | | budget.Property(x => x.WindowEndsAt).IsRequired(); |
| | | 22 | | |
| | | 23 | | // The purge reads budgets whose window ended before the grace period. |
| | 3 | 24 | | budget.HasIndex(x => x.WindowEndsAt); |
| | 3 | 25 | | } |
| | | 26 | | } |