Files
SVSimServer/SVSim.Database/Migrations/20260528024430_AddLeaderSkinShop.cs
gamer147 a5999a3e9c feat(leader-skin): shop catalog + 5 endpoints (/products, /buy, /buy_set, /buy_set_item, /ids)
Schema: LeaderSkinShopSeries -> Products (owned rewards) + owned
SetCompletionRewards on the series; ViewerLeaderSkinSetClaim composite
PK (ViewerId, SeriesId) backs the /buy_set_item idempotent-claim check.

Importer mirrors SleeveShopImporter: idempotent find-or-create, owned
collections rewritten wholesale on rerun. 16 series, 104 products.

Controller (extends existing /set with 5 new endpoints):
- /products: dict-keyed-by-series_id-string wire shape. is_completed
  per-viewer, rewards.status from ViewerLeaderSkinSetClaim (0=no set
  sale, 1=available, 2=claimed) matching client RewardStatus enum.
- /buy: single skin, sales_type 1/2 dispatch, 3=>501.
- /buy_set: whole series at SetPrice; requires set_sales_status != 0;
  grants every product's rewards (RewardGrantService idempotent on
  already-owned cosmetics, so partial-set buys don't double-add).
- /buy_set_item: requires viewer owns every skin in series; idempotent
  on re-claim (returns 200 + empty reward_list, not 400) so client
  retries don't error.
- /ids: flat owned-skin-id list for badge refresh.

496 tests pass (was 486; +10 leader-skin-shop tests).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:55:09 -04:00

156 lines
7.9 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace SVSim.Database.Migrations
{
/// <inheritdoc />
public partial class AddLeaderSkinShop : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "LeaderSkinShopSeries",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false),
IsNew = table.Column<bool>(type: "boolean", nullable: false),
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
SetSalesStatus = table.Column<int>(type: "integer", nullable: false),
SetPriceCrystal = table.Column<int>(type: "integer", nullable: true),
SetPriceRupy = table.Column<int>(type: "integer", nullable: true),
SetPriceTicket = table.Column<int>(type: "integer", nullable: true),
SetPriceTicketId = table.Column<long>(type: "bigint", nullable: true),
SetCompletionRewardStatus = table.Column<int>(type: "integer", 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_LeaderSkinShopSeries", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ViewerLeaderSkinSetClaims",
columns: table => new
{
ViewerId = table.Column<long>(type: "bigint", nullable: false),
SeriesId = table.Column<int>(type: "integer", nullable: false),
ClaimedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ViewerLeaderSkinSetClaims", x => new { x.ViewerId, x.SeriesId });
});
migrationBuilder.CreateTable(
name: "LeaderSkinShopProducts",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false),
SeriesId = table.Column<int>(type: "integer", nullable: false),
LeaderSkinId = table.Column<int>(type: "integer", nullable: false),
ProductNameKey = table.Column<string>(type: "text", nullable: false),
IntroductionKey = table.Column<string>(type: "text", nullable: false),
CvNameKey = table.Column<string>(type: "text", nullable: false),
SinglePriceCrystal = table.Column<int>(type: "integer", nullable: true),
SinglePriceRupy = table.Column<int>(type: "integer", nullable: true),
SinglePriceTicket = table.Column<int>(type: "integer", nullable: true),
TicketNumber = table.Column<int>(type: "integer", nullable: true),
TicketItemId = table.Column<long>(type: "bigint", nullable: true),
IsEnabled = 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_LeaderSkinShopProducts", x => x.Id);
table.ForeignKey(
name: "FK_LeaderSkinShopProducts_LeaderSkinShopSeries_SeriesId",
column: x => x.SeriesId,
principalTable: "LeaderSkinShopSeries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "LeaderSkinShopSeriesRewardEntry",
columns: table => new
{
LeaderSkinShopSeriesEntryId = table.Column<int>(type: "integer", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
OrderIndex = 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)
},
constraints: table =>
{
table.PrimaryKey("PK_LeaderSkinShopSeriesRewardEntry", x => new { x.LeaderSkinShopSeriesEntryId, x.Id });
table.ForeignKey(
name: "FK_LeaderSkinShopSeriesRewardEntry_LeaderSkinShopSeries_Leader~",
column: x => x.LeaderSkinShopSeriesEntryId,
principalTable: "LeaderSkinShopSeries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "LeaderSkinShopProductRewardEntry",
columns: table => new
{
LeaderSkinShopProductEntryId = table.Column<int>(type: "integer", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
OrderIndex = 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)
},
constraints: table =>
{
table.PrimaryKey("PK_LeaderSkinShopProductRewardEntry", x => new { x.LeaderSkinShopProductEntryId, x.Id });
table.ForeignKey(
name: "FK_LeaderSkinShopProductRewardEntry_LeaderSkinShopProducts_Lea~",
column: x => x.LeaderSkinShopProductEntryId,
principalTable: "LeaderSkinShopProducts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_LeaderSkinShopProducts_SeriesId",
table: "LeaderSkinShopProducts",
column: "SeriesId");
migrationBuilder.CreateIndex(
name: "IX_ViewerLeaderSkinSetClaims_ViewerId",
table: "ViewerLeaderSkinSetClaims",
column: "ViewerId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LeaderSkinShopProductRewardEntry");
migrationBuilder.DropTable(
name: "LeaderSkinShopSeriesRewardEntry");
migrationBuilder.DropTable(
name: "ViewerLeaderSkinSetClaims");
migrationBuilder.DropTable(
name: "LeaderSkinShopProducts");
migrationBuilder.DropTable(
name: "LeaderSkinShopSeries");
}
}
}