feat(account): add deletion lifecycle
CI and Deploy / test (pull_request) Successful in 5m18s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-15 19:03:54 +02:00
parent 1ec9dd037e
commit 842e793f69
28 changed files with 4418 additions and 129 deletions
+28
View File
@@ -63,6 +63,8 @@ namespace JobTrackerApi.Data
public DbSet<UserNotification> UserNotifications => Set<UserNotification>();
public DbSet<EmailSendAttempt> EmailSendAttempts => Set<EmailSendAttempt>();
public DbSet<EmailDraft> EmailDrafts => Set<EmailDraft>();
public DbSet<AccountDeletionRequest> AccountDeletionRequests => Set<AccountDeletionRequest>();
public DbSet<AccountDeletionFile> AccountDeletionFiles => Set<AccountDeletionFile>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -80,6 +82,32 @@ namespace JobTrackerApi.Data
.Property(x => x.MicrosoftObjectId)
.HasMaxLength(36);
modelBuilder.Entity<ApplicationUser>()
.Property(x => x.DeletionStatus)
.HasMaxLength(32)
.HasDefaultValue(AccountDeletionStatuses.Active);
modelBuilder.Entity<AccountDeletionRequest>().Property(x => x.OwnerUserId).HasMaxLength(255);
modelBuilder.Entity<AccountDeletionRequest>().Property(x => x.OwnerKey).HasMaxLength(64);
modelBuilder.Entity<AccountDeletionRequest>().Property(x => x.RequestedByUserId).HasMaxLength(255);
modelBuilder.Entity<AccountDeletionRequest>().Property(x => x.Status).HasMaxLength(32);
modelBuilder.Entity<AccountDeletionRequest>().Property(x => x.Stage).HasMaxLength(32);
modelBuilder.Entity<AccountDeletionRequest>().Property(x => x.LastErrorCategory).HasMaxLength(64);
modelBuilder.Entity<AccountDeletionRequest>()
.HasIndex(x => new { x.OwnerUserId, x.Status });
modelBuilder.Entity<AccountDeletionRequest>()
.HasIndex(x => new { x.Status, x.RequestedAtUtc });
modelBuilder.Entity<AccountDeletionFile>().Property(x => x.Category).HasMaxLength(64);
modelBuilder.Entity<AccountDeletionFile>().Property(x => x.Status).HasMaxLength(32);
modelBuilder.Entity<AccountDeletionFile>().Property(x => x.Sha256).HasMaxLength(64);
modelBuilder.Entity<AccountDeletionFile>()
.HasIndex(x => new { x.AccountDeletionRequestId, x.Status });
modelBuilder.Entity<AccountDeletionFile>()
.HasOne(x => x.Request)
.WithMany(x => x.Files)
.HasForeignKey(x => x.AccountDeletionRequestId)
.OnDelete(DeleteBehavior.Cascade);
// Both supported databases allow multiple NULL values in a unique index, so legacy
// rows remain unassigned while each proven tenant/object pair has exactly one owner.
modelBuilder.Entity<ApplicationUser>()