feat(bp): repositories + identity generation for runtime-inserted tables
Add ValueGeneratedOnAdd to ViewerBattlePassProgress.Id and ViewerBattlePassClaims.Id so Postgres generates IDENTITY values at runtime. Regenerate AddBattlePass migration in-place to include the IdentityByDefaultColumn annotations. Add IBattlePassRepository / BattlePassRepository (season lookup + level-curve cache) and IViewerBattlePassRepository / ViewerBattlePassRepository (get-or-create progress, claim reads/writes). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ using SVSim.Database;
|
||||
namespace SVSim.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(SVSimDbContext))]
|
||||
[Migration("20260527021011_AddBattlePass")]
|
||||
[Migration("20260527023819_AddBattlePass")]
|
||||
partial class AddBattlePass
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -1908,8 +1908,11 @@ namespace SVSim.Database.Migrations
|
||||
modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassClaimEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTimeOffset>("ClaimedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
@@ -1944,8 +1947,11 @@ namespace SVSim.Database.Migrations
|
||||
modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassProgressEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("CurrentPoint")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@@ -35,7 +36,8 @@ namespace SVSim.Database.Migrations
|
||||
name: "ViewerBattlePassClaims",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false),
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ViewerId = table.Column<long>(type: "bigint", nullable: false),
|
||||
SeasonId = table.Column<int>(type: "integer", nullable: false),
|
||||
Track = table.Column<int>(type: "integer", nullable: false),
|
||||
@@ -53,7 +55,8 @@ namespace SVSim.Database.Migrations
|
||||
name: "ViewerBattlePassProgress",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false),
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ViewerId = table.Column<long>(type: "bigint", nullable: false),
|
||||
SeasonId = table.Column<int>(type: "integer", nullable: false),
|
||||
CurrentPoint = table.Column<int>(type: "integer", nullable: false),
|
||||
@@ -1905,8 +1905,11 @@ namespace SVSim.Database.Migrations
|
||||
modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassClaimEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTimeOffset>("ClaimedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
@@ -1941,8 +1944,11 @@ namespace SVSim.Database.Migrations
|
||||
modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassProgressEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("CurrentPoint")
|
||||
.HasColumnType("integer");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user