| | | 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 ErasedSubjectDbMap |
| | | 8 | | { |
| | | 9 | | public static void Configure(this EntityTypeBuilder<ErasedSubject> erasedSubject) |
| | | 10 | | { |
| | 3 | 11 | | erasedSubject.ToTable("erased_subject"); |
| | | 12 | | |
| | | 13 | | // The key is the removed identity's PublicId (#195): the trail's target_id is looked up here |
| | | 14 | | // directly, and an id can be tombstoned only once. Never generated — it is copied from the |
| | | 15 | | // row being deleted. |
| | 3 | 16 | | erasedSubject.HasKey(x => x.Id); |
| | 3 | 17 | | erasedSubject.Property(x => x.Id).HasColumnName("public_id").ValueGeneratedNever(); |
| | | 18 | | |
| | 3 | 19 | | erasedSubject.Property(x => x.Kind).IsRequired(); |
| | 3 | 20 | | erasedSubject.Property(x => x.CreatedAt).HasDefaultValueSql("now()"); |
| | | 21 | | |
| | | 22 | | // The pass's cleanup reads tombstones older than the grace period. |
| | 3 | 23 | | erasedSubject.HasIndex(x => x.CreatedAt); |
| | | 24 | | |
| | | 25 | | // No foreign key to person or google_user: the row it names is about to be deleted, and the |
| | | 26 | | // tombstone has to outlive it. |
| | 3 | 27 | | } |
| | | 28 | | } |