feat(replay): add ViewerBattleHistory entity + migration
New table backs /replay/info; composite PK (ViewerId, BattleId), index on (ViewerId, CreateTime) for the newest-first list query. 50-row per-viewer retention enforced by BattleHistoryWriter (next commit). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -115,6 +115,7 @@ public class SVSimDbContext : DbContext
|
||||
public DbSet<ViewerFriend> ViewerFriends => Set<ViewerFriend>();
|
||||
public DbSet<ViewerFriendApply> ViewerFriendApplies => Set<ViewerFriendApply>();
|
||||
public DbSet<ViewerPlayedTogether> ViewerPlayedTogethers => Set<ViewerPlayedTogether>();
|
||||
public DbSet<ViewerBattleHistory> ViewerBattleHistories => Set<ViewerBattleHistory>();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -484,6 +485,17 @@ public class SVSimDbContext : DbContext
|
||||
// OpponentViewerId is NOT an FK — we want survivors' history to outlive a deleted opponent.
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ViewerBattleHistory>(b =>
|
||||
{
|
||||
b.HasKey(e => new { e.ViewerId, e.BattleId });
|
||||
b.HasIndex(e => new { e.ViewerId, e.CreateTime })
|
||||
.HasDatabaseName("IX_ViewerBattleHistories_ViewerId_CreateTime");
|
||||
b.Property(e => e.SelfRotationId).IsRequired();
|
||||
b.Property(e => e.OpponentName).IsRequired();
|
||||
b.Property(e => e.OpponentCountryCode).IsRequired();
|
||||
b.Property(e => e.OpponentRotationId).IsRequired();
|
||||
});
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user