db: add nullable Viewer.Udid with partial unique index
Backstop for /tool/signup idempotency: signup-created viewers carry the client's UDID (the AES key for that client's wire traffic); admin-imported viewers stay null. Partial unique index allows the column to coexist with pre-existing null rows. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
3268
SVSim.Database/Migrations/20260527175337_AddViewerUdid.Designer.cs
generated
Normal file
3268
SVSim.Database/Migrations/20260527175337_AddViewerUdid.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
40
SVSim.Database/Migrations/20260527175337_AddViewerUdid.cs
Normal file
40
SVSim.Database/Migrations/20260527175337_AddViewerUdid.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SVSim.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddViewerUdid : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Udid",
|
||||
table: "Viewers",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Viewers_Udid",
|
||||
table: "Viewers",
|
||||
column: "Udid",
|
||||
unique: true,
|
||||
filter: "\"Udid\" IS NOT NULL");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Viewers_Udid",
|
||||
table: "Viewers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Udid",
|
||||
table: "Viewers");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2052,10 +2052,16 @@ namespace SVSim.Database.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseSequence(b.Property<long>("ShortUdid"), "ShortUdidSequence");
|
||||
|
||||
b.Property<Guid?>("Udid")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ShortUdid");
|
||||
|
||||
b.HasIndex("Udid")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Viewers");
|
||||
});
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace SVSim.Database.Models;
|
||||
/// A user within the game system.
|
||||
/// </summary>
|
||||
[Index(nameof(ShortUdid))]
|
||||
[Index(nameof(Udid), IsUnique = true)]
|
||||
public class Viewer : BaseEntity<long>
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
@@ -17,11 +18,18 @@ public class Viewer : BaseEntity<long>
|
||||
/// This user's name displayed in game.
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; } = String.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This user's short identifier.
|
||||
/// </summary>
|
||||
public long ShortUdid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The client's full UDID (AES key for the wire protocol). Set when the viewer is created
|
||||
/// via <c>/tool/signup</c>; null for viewers created via the admin Steam-import path. Unique
|
||||
/// when present — the partial filter is declared in the migration.
|
||||
/// </summary>
|
||||
public Guid? Udid { get; set; }
|
||||
|
||||
public DateTime LastLogin { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user