fix(gift): drop RowVersion (SQLite incompatible) + restore wire reward_type map

[Timestamp] byte[] doesn't work under SQLite (the test backend) — EF
expects the DB to populate it on insert, but SQLite has no equivalent
of Postgres's xmin. The WHERE Status = Unclaimed filter plus
IInventoryService's viewer-level concurrency is the practical defense;
RowVersion was only a backstop. Regenerated the migration without the
RowVersion column.

Wire reward_type on the gift endpoint uses a gift-specific scheme that
diverges from UserGoodsType for currencies: wire 1 = Crystal (enum=2),
wire 9 = Rupy (enum=9), wire 4 = Item (enum=4). A naked cast resolves
wire 1 to UserGoodsType.RedEther and silently grants the wrong wallet
— restored the explicit WireRewardTypeToUserGoodsType map from the old
tutorial controller.

Retrofits existing GiftControllerTests to call SeedTutorialPresentsAsync
on the new helper (RegisterViewer doesn't auto-seed; only the prod
signup path does). All 7 existing tests pass.
This commit is contained in:
gamer147
2026-06-08 20:44:52 -04:00
parent ca36792be3
commit f1d881b26a
6 changed files with 22 additions and 25 deletions

View File

@@ -12,7 +12,7 @@ using SVSim.Database;
namespace SVSim.Database.Migrations
{
[DbContext(typeof(SVSimDbContext))]
[Migration("20260609003820_AddViewerPresents")]
[Migration("20260609004113_AddViewerPresents")]
partial class AddViewerPresents
{
/// <inheritdoc />
@@ -2902,12 +2902,6 @@ namespace SVSim.Database.Migrations
b.Property<int>("RewardType")
.HasColumnType("integer");
b.Property<byte[]>("RowVersion")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("bytea");
b.Property<string>("Source")
.HasMaxLength(64)
.HasColumnType("character varying(64)");

View File

@@ -34,8 +34,7 @@ namespace SVSim.Database.Migrations
Message = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ClaimedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Source = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
RowVersion = table.Column<byte[]>(type: "bytea", rowVersion: true, nullable: false)
Source = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true)
},
constraints: table =>
{

View File

@@ -2899,12 +2899,6 @@ namespace SVSim.Database.Migrations
b.Property<int>("RewardType")
.HasColumnType("integer");
b.Property<byte[]>("RowVersion")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("bytea");
b.Property<string>("Source")
.HasMaxLength(64)
.HasColumnType("character varying(64)");

View File

@@ -1,5 +1,3 @@
using System.ComponentModel.DataAnnotations;
namespace SVSim.Database.Models;
/// <summary>
@@ -39,13 +37,6 @@ public class ViewerPresent
/// this today — the tutorial-step advance is route-gated, not Source-gated.
/// </summary>
public string? Source { get; set; }
/// <summary>
/// EF Core optimistic concurrency for the claim path. Two concurrent claims of the
/// same PresentId: first wins, second's CommitAsync throws DbUpdateConcurrencyException.
/// </summary>
[Timestamp]
public byte[] RowVersion { get; set; } = Array.Empty<byte>();
}
public enum PresentStatus : byte