DB Cleanup
This commit is contained in:
@@ -126,6 +126,21 @@ public class SVSimDbContext : DbContext
|
||||
modelBuilder.Entity<PackConfigEntry>().OwnsMany(p => p.Banners);
|
||||
modelBuilder.Entity<Viewer>().OwnsMany(v => v.PackOpenCounts);
|
||||
|
||||
// OwnedCardEntry and OwnedItemEntry use composite PK (ViewerId, Id) where Id is auto-
|
||||
// generated, which silently permits multiple rows per (Viewer, Card) or (Viewer, Item).
|
||||
// The intended semantic is one row per pair with Count as multiplicity — enforce that as
|
||||
// a unique index so any future find-or-add that forgets to .Include the collection (and
|
||||
// therefore re-creates a row that already exists in the DB) crashes loudly at SaveChanges
|
||||
// instead of silently duplicating ownership rows.
|
||||
modelBuilder.Entity<Viewer>().OwnsMany(v => v.Cards, b =>
|
||||
{
|
||||
b.HasIndex("ViewerId", "CardId").IsUnique();
|
||||
});
|
||||
modelBuilder.Entity<Viewer>().OwnsMany(v => v.Items, b =>
|
||||
{
|
||||
b.HasIndex("ViewerId", "ItemId").IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CardCosmeticReward>(b =>
|
||||
{
|
||||
b.HasKey(r => new { r.CardId, r.Type, r.CosmeticId });
|
||||
|
||||
Reference in New Issue
Block a user