feat(db): AddArenaTwoPick migration (rewards + viewer-run tables)
Register ArenaTwoPickRewards and ViewerArenaTwoPickRuns DbSets in SVSimDbContext and generate the AddArenaTwoPick migration with both CreateTable calls, all four jsonb columns on the run table, and the correct indexes (WinCount scalar + unique WinCount/RewardType/RewardId on rewards; unique ViewerId on runs).
This commit is contained in:
4037
SVSim.Database/Migrations/20260531141959_AddArenaTwoPick.Designer.cs
generated
Normal file
4037
SVSim.Database/Migrations/20260531141959_AddArenaTwoPick.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
90
SVSim.Database/Migrations/20260531141959_AddArenaTwoPick.cs
Normal file
90
SVSim.Database/Migrations/20260531141959_AddArenaTwoPick.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SVSim.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddArenaTwoPick : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ArenaTwoPickRewards",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
WinCount = table.Column<int>(type: "integer", nullable: false),
|
||||
RewardType = table.Column<int>(type: "integer", nullable: false),
|
||||
RewardId = table.Column<long>(type: "bigint", nullable: false),
|
||||
RewardNum = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ArenaTwoPickRewards", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ViewerArenaTwoPickRuns",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ViewerId = table.Column<long>(type: "bigint", nullable: false),
|
||||
EntryId = table.Column<long>(type: "bigint", nullable: false),
|
||||
RewardScheduleId = table.Column<int>(type: "integer", nullable: false),
|
||||
ChallengeId = table.Column<int>(type: "integer", nullable: false),
|
||||
MaxBattleCount = table.Column<int>(type: "integer", nullable: false),
|
||||
ClassId = table.Column<int>(type: "integer", nullable: false),
|
||||
LeaderSkinId = table.Column<long>(type: "bigint", nullable: false),
|
||||
CandidateClassIdsJson = table.Column<string>(type: "jsonb", nullable: false),
|
||||
SelectTurn = table.Column<int>(type: "integer", nullable: false),
|
||||
IsSelectCompleted = table.Column<bool>(type: "boolean", nullable: false),
|
||||
SelectedCardIdsJson = table.Column<string>(type: "jsonb", nullable: false),
|
||||
PendingPickSetsJson = table.Column<string>(type: "jsonb", nullable: false),
|
||||
NextCandidateId = table.Column<long>(type: "bigint", nullable: false),
|
||||
ResultListJson = table.Column<string>(type: "jsonb", nullable: false),
|
||||
WinCount = table.Column<int>(type: "integer", nullable: false),
|
||||
LossCount = table.Column<int>(type: "integer", nullable: false),
|
||||
IsRetire = table.Column<bool>(type: "boolean", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ViewerArenaTwoPickRuns", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ArenaTwoPickRewards_WinCount",
|
||||
table: "ArenaTwoPickRewards",
|
||||
column: "WinCount");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ArenaTwoPickRewards_WinCount_RewardType_RewardId",
|
||||
table: "ArenaTwoPickRewards",
|
||||
columns: new[] { "WinCount", "RewardType", "RewardId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ViewerArenaTwoPickRuns_ViewerId",
|
||||
table: "ViewerArenaTwoPickRuns",
|
||||
column: "ViewerId",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ArenaTwoPickRewards");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ViewerArenaTwoPickRuns");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,6 +450,36 @@ namespace SVSim.Database.Migrations
|
||||
b.ToTable("ArenaSeasons");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.ArenaTwoPickReward", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<long>("RewardId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("RewardNum")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RewardType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("WinCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WinCount");
|
||||
|
||||
b.HasIndex("WinCount", "RewardType", "RewardId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ArenaTwoPickRewards");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.AvatarAbilityEntry", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -2482,6 +2512,83 @@ namespace SVSim.Database.Migrations
|
||||
b.ToTable("ViewerAchievements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.ViewerArenaTwoPickRun", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("CandidateClassIdsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<int>("ChallengeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ClassId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long>("EntryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<bool>("IsRetire")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsSelectCompleted")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<long>("LeaderSkinId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("LossCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MaxBattleCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("NextCandidateId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("PendingPickSetsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<string>("ResultListJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<int>("RewardScheduleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SelectTurn")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("SelectedCardIdsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long>("ViewerId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("WinCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ViewerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ViewerArenaTwoPickRuns");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassClaimEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
|
||||
@@ -101,6 +101,9 @@ public class SVSimDbContext : DbContext
|
||||
|
||||
public DbSet<ViewerClaimedTutorialGift> ViewerClaimedTutorialGifts => Set<ViewerClaimedTutorialGift>();
|
||||
|
||||
public DbSet<ArenaTwoPickReward> ArenaTwoPickRewards { get; set; } = null!;
|
||||
public DbSet<ViewerArenaTwoPickRun> ViewerArenaTwoPickRuns { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
|
||||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
|
||||
Reference in New Issue
Block a user