feat(bp): wire 4 new entities into DbContext + AddBattlePass migration

Adds DbSets and OnModelCreating config for BattlePassSeasonEntry,
BattlePassRewardEntry, ViewerBattlePassProgressEntry, and
ViewerBattlePassClaimEntry; generates migration 20260527021011_AddBattlePass
with DDL-only CreateTable + CreateIndex calls and no InsertData.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-05-26 22:12:55 -04:00
parent faa8c0e6dd
commit 3f784f4294
4 changed files with 3323 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,142 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SVSim.Database.Migrations
{
/// <inheritdoc />
public partial class AddBattlePass : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BattlePassSeasons",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
MaxLevel = table.Column<int>(type: "integer", nullable: false),
StartDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
EndDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
CanPurchase = table.Column<bool>(type: "boolean", nullable: false),
PriceCrystal = table.Column<int>(type: "integer", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BattlePassSeasons", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ViewerBattlePassClaims",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
ViewerId = table.Column<long>(type: "bigint", nullable: false),
SeasonId = table.Column<int>(type: "integer", nullable: false),
Track = table.Column<int>(type: "integer", nullable: false),
Level = table.Column<int>(type: "integer", nullable: false),
ClaimedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ViewerBattlePassClaims", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ViewerBattlePassProgress",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
ViewerId = table.Column<long>(type: "bigint", nullable: false),
SeasonId = table.Column<int>(type: "integer", nullable: false),
CurrentPoint = table.Column<int>(type: "integer", nullable: false),
IsPremium = table.Column<bool>(type: "boolean", nullable: false),
WeeklyPoints = table.Column<int>(type: "integer", nullable: false),
WeeklyPeriodStart = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ViewerBattlePassProgress", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BattlePassRewards",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
SeasonId = table.Column<int>(type: "integer", nullable: false),
Track = table.Column<int>(type: "integer", nullable: false),
Level = table.Column<int>(type: "integer", nullable: false),
RewardType = table.Column<int>(type: "integer", nullable: false),
RewardDetailId = table.Column<long>(type: "bigint", nullable: false),
RewardNumber = table.Column<int>(type: "integer", nullable: false),
IsAppealExclusion = table.Column<bool>(type: "boolean", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BattlePassRewards", x => x.Id);
table.ForeignKey(
name: "FK_BattlePassRewards_BattlePassSeasons_SeasonId",
column: x => x.SeasonId,
principalTable: "BattlePassSeasons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_BattlePassRewards_SeasonId_Track_Level",
table: "BattlePassRewards",
columns: new[] { "SeasonId", "Track", "Level" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_BattlePassSeasons_StartDate_EndDate",
table: "BattlePassSeasons",
columns: new[] { "StartDate", "EndDate" });
migrationBuilder.CreateIndex(
name: "IX_ViewerBattlePassClaims_ViewerId_SeasonId",
table: "ViewerBattlePassClaims",
columns: new[] { "ViewerId", "SeasonId" });
migrationBuilder.CreateIndex(
name: "IX_ViewerBattlePassClaims_ViewerId_SeasonId_Track_Level",
table: "ViewerBattlePassClaims",
columns: new[] { "ViewerId", "SeasonId", "Track", "Level" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ViewerBattlePassProgress_ViewerId_SeasonId",
table: "ViewerBattlePassProgress",
columns: new[] { "ViewerId", "SeasonId" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BattlePassRewards");
migrationBuilder.DropTable(
name: "ViewerBattlePassClaims");
migrationBuilder.DropTable(
name: "ViewerBattlePassProgress");
migrationBuilder.DropTable(
name: "BattlePassSeasons");
}
}
}

View File

@@ -516,6 +516,87 @@ namespace SVSim.Database.Migrations
b.ToTable("BattlePassLevels");
});
modelBuilder.Entity("SVSim.Database.Models.BattlePassRewardEntry", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsAppealExclusion")
.HasColumnType("boolean");
b.Property<int>("Level")
.HasColumnType("integer");
b.Property<long>("RewardDetailId")
.HasColumnType("bigint");
b.Property<int>("RewardNumber")
.HasColumnType("integer");
b.Property<int>("RewardType")
.HasColumnType("integer");
b.Property<int>("SeasonId")
.HasColumnType("integer");
b.Property<int>("Track")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SeasonId", "Track", "Level")
.IsUnique();
b.ToTable("BattlePassRewards");
});
modelBuilder.Entity("SVSim.Database.Models.BattlePassSeasonEntry", b =>
{
b.Property<int>("Id")
.HasColumnType("integer");
b.Property<bool>("CanPurchase")
.HasColumnType("boolean");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("EndDate")
.HasColumnType("timestamp with time zone");
b.Property<int>("MaxLevel")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PriceCrystal")
.HasColumnType("integer");
b.Property<DateTimeOffset>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("StartDate", "EndDate");
b.ToTable("BattlePassSeasons");
});
modelBuilder.Entity("SVSim.Database.Models.BattlefieldEntry", b =>
{
b.Property<int>("Id")
@@ -1821,6 +1902,79 @@ namespace SVSim.Database.Migrations
b.ToTable("Viewers");
});
modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassClaimEntry", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<DateTimeOffset>("ClaimedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone");
b.Property<int>("Level")
.HasColumnType("integer");
b.Property<int>("SeasonId")
.HasColumnType("integer");
b.Property<int>("Track")
.HasColumnType("integer");
b.Property<long>("ViewerId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ViewerId", "SeasonId");
b.HasIndex("ViewerId", "SeasonId", "Track", "Level")
.IsUnique();
b.ToTable("ViewerBattlePassClaims");
});
modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassProgressEntry", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<int>("CurrentPoint")
.HasColumnType("integer");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsPremium")
.HasColumnType("boolean");
b.Property<int>("SeasonId")
.HasColumnType("integer");
b.Property<long>("ViewerId")
.HasColumnType("bigint");
b.Property<DateTimeOffset?>("WeeklyPeriodStart")
.HasColumnType("timestamp with time zone");
b.Property<int>("WeeklyPoints")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ViewerId", "SeasonId")
.IsUnique();
b.ToTable("ViewerBattlePassProgress");
});
modelBuilder.Entity("SVSim.Database.Models.ViewerPuzzleClear", b =>
{
b.Property<long>("ViewerId")
@@ -2043,6 +2197,17 @@ namespace SVSim.Database.Migrations
b.Navigation("World");
});
modelBuilder.Entity("SVSim.Database.Models.BattlePassRewardEntry", b =>
{
b.HasOne("SVSim.Database.Models.BattlePassSeasonEntry", "Season")
.WithMany("Rewards")
.HasForeignKey("SeasonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Season");
});
modelBuilder.Entity("SVSim.Database.Models.BuildDeckProductEntry", b =>
{
b.HasOne("SVSim.Database.Models.BuildDeckSeriesEntry", "Series")
@@ -2775,6 +2940,11 @@ namespace SVSim.Database.Migrations
.IsRequired();
});
modelBuilder.Entity("SVSim.Database.Models.BattlePassSeasonEntry", b =>
{
b.Navigation("Rewards");
});
modelBuilder.Entity("SVSim.Database.Models.BuildDeckSeriesEntry", b =>
{
b.Navigation("Products");

View File

@@ -50,6 +50,10 @@ public class SVSimDbContext : DbContext
public DbSet<UnlimitedRestrictionEntry> UnlimitedRestrictions => Set<UnlimitedRestrictionEntry>();
public DbSet<LoadingExclusionCardEntry> LoadingExclusionCards => Set<LoadingExclusionCardEntry>();
public DbSet<BattlePassLevelEntry> BattlePassLevels => Set<BattlePassLevelEntry>();
public DbSet<BattlePassSeasonEntry> BattlePassSeasons => Set<BattlePassSeasonEntry>();
public DbSet<BattlePassRewardEntry> BattlePassRewards => Set<BattlePassRewardEntry>();
public DbSet<ViewerBattlePassProgressEntry> ViewerBattlePassProgress => Set<ViewerBattlePassProgressEntry>();
public DbSet<ViewerBattlePassClaimEntry> ViewerBattlePassClaims => Set<ViewerBattlePassClaimEntry>();
public DbSet<DailyLoginBonusEntry> DailyLoginBonuses => Set<DailyLoginBonusEntry>();
public DbSet<BannerEntry> Banners => Set<BannerEntry>();
public DbSet<ColosseumConfig> Colosseums => Set<ColosseumConfig>();
@@ -207,6 +211,35 @@ public class SVSimDbContext : DbContext
modelBuilder.Entity<StoryChapter>().HasIndex(c => new { c.SectionId, c.CharaId, c.ChapterId });
modelBuilder.Entity<StoryChapter>().HasIndex(c => c.NextChapterId);
// --- Battle pass entities ---
modelBuilder.Entity<BattlePassSeasonEntry>(b =>
{
b.HasKey(e => e.Id);
b.Property(e => e.Id).ValueGeneratedNever();
b.HasIndex(e => new { e.StartDate, e.EndDate });
b.HasMany(e => e.Rewards).WithOne(r => r.Season).HasForeignKey(r => r.SeasonId).OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<BattlePassRewardEntry>(b =>
{
b.HasKey(e => e.Id);
b.HasIndex(e => new { e.SeasonId, e.Track, e.Level }).IsUnique();
});
modelBuilder.Entity<ViewerBattlePassProgressEntry>(b =>
{
b.HasKey(e => e.Id);
b.HasIndex(e => new { e.ViewerId, e.SeasonId }).IsUnique();
});
modelBuilder.Entity<ViewerBattlePassClaimEntry>(b =>
{
b.HasKey(e => e.Id);
b.HasIndex(e => new { e.ViewerId, e.SeasonId, e.Track, e.Level }).IsUnique();
b.HasIndex(e => new { e.ViewerId, e.SeasonId });
});
base.OnModelCreating(modelBuilder);
}