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

View File

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