feat(viewer): add LastLoginBonusClaimedAt + LoginBonusStreak columns

Drops the unused daily_login_bonuses table in the same migration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-13 15:42:40 -04:00
parent f707fb2ffb
commit 107ee106a3
4 changed files with 4854 additions and 23 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SVSim.Database.Migrations
{
/// <inheritdoc />
public partial class AddViewerLoginBonusState : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DailyLoginBonuses");
migrationBuilder.AddColumn<DateTime>(
name: "LastLoginBonusClaimedAt",
table: "Viewers",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "LoginBonusStreak",
table: "Viewers",
type: "integer",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LastLoginBonusClaimedAt",
table: "Viewers");
migrationBuilder.DropColumn(
name: "LoginBonusStreak",
table: "Viewers");
migrationBuilder.CreateTable(
name: "DailyLoginBonuses",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false),
BonusData = table.Column<string>(type: "jsonb", nullable: false),
BonusId = 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_DailyLoginBonuses", x => x.Id);
});
}
}
}

View File

@@ -1075,29 +1075,6 @@ namespace SVSim.Database.Migrations
b.ToTable("ColosseumWindFallDecks");
});
modelBuilder.Entity("SVSim.Database.Models.DailyLoginBonusEntry", b =>
{
b.Property<int>("Id")
.HasColumnType("integer");
b.Property<string>("BonusData")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("BonusId")
.HasColumnType("integer");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("DailyLoginBonuses");
});
modelBuilder.Entity("SVSim.Database.Models.DefaultDeckEntry", b =>
{
b.Property<int>("Id")
@@ -2711,6 +2688,12 @@ namespace SVSim.Database.Migrations
b.Property<DateTime>("LastLogin")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("LastLoginBonusClaimedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("LoginBonusStreak")
.HasColumnType("integer");
b.Property<int>("MyPageBgId")
.HasColumnType("integer");

View File

@@ -33,6 +33,18 @@ public class Viewer : BaseEntity<long>
public DateTime LastLogin { get; set; }
/// <summary>
/// UTC instant of the most recent daily-login-bonus claim. Null = never claimed.
/// Compared against JST 02:00 day boundary via JstPeriod.DayKey to decide eligibility.
/// </summary>
public DateTime? LastLoginBonusClaimedAt { get; set; }
/// <summary>
/// 1-based position in the Normal login-bonus cycle. 0 = never claimed (first claim
/// will write 1). Wraps back to 1 after reaching cycle length (LoginBonusConfig.Normal.Count).
/// </summary>
public int LoginBonusStreak { get; set; }
/// <summary>BGType enum: 0=Deck, 1=CustomBG, 2=RandomBG. Default 0 = follow equipped deck's leader skin.</summary>
public int MyPageBgSelectType { get; set; }