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:
gamer147
2026-05-27 13:54:15 -04:00
parent 8e35501954
commit dffd7a9746
4 changed files with 3323 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View 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");
}
}
}

View File

@@ -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");
});