Account merge ledger: fix the first Soul pass (suspension carried into a memberless survivor, merged status terminal, standing at the desk door, linked accounts and write time, journalled grace intake, survivor weight on moved votes, one-hop alias, State token and database guards for overlapping merges, live-Postgres tests)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
84ff2c4578
commit
f402eb13cc
23 changed files with 1273 additions and 97 deletions
|
|
@ -628,9 +628,16 @@ public sealed class BifrostDbContext(DbContextOptions<BifrostDbContext> options)
|
|||
|
||||
modelBuilder.Entity<AccountMerge>(entity =>
|
||||
{
|
||||
entity.Property(x => x.State).HasConversion<string>().HasMaxLength(24);
|
||||
// State is the token: a transition computed from a stale read (the sweeper's Final over a saga's UndoRequested) fails its save.
|
||||
entity.Property(x => x.State).HasConversion<string>().HasMaxLength(24).IsConcurrencyToken();
|
||||
entity.Property(x => x.FailureCode).HasMaxLength(64);
|
||||
entity.HasIndex(x => new { x.FoldedUserAccountId, x.State });
|
||||
// An account is folded once: the DB refuses a second live merge folding it. The cross-role case (a survivor that is also
|
||||
// folded) cannot be one unique index; the migration's trigger refuses it.
|
||||
entity.HasIndex(x => x.FoldedUserAccountId)
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UX_AccountMerges_FoldedUserAccountId_Live")
|
||||
.HasFilter("\"State\" IN ('Confirmed', 'HeimdallMoved', 'Committed', 'Final', 'UndoRequested', 'HeimdallReversed')");
|
||||
entity.HasIndex(x => new { x.SurvivorUserAccountId, x.State });
|
||||
entity.HasIndex(x => new { x.State, x.GraceEndsUtc });
|
||||
entity.HasOne<UserAccount>()
|
||||
|
|
|
|||
Loading…
Reference in a new issue