Add versioning, content, and chat presence/notifications services

- SOR.Versioning: version.check handler, ClientRelease entity + admin UI
- SOR.Content: incremental card sync (DefinitionVersion cursor via Postgres trigger),
  content.sync / content.sets / content.card handlers
- Chat: presence (account_presence) + notifications with unread count and mark-read
- CardDefinition: DefinitionVersion bigint (trigger-assigned) + IsRetired soft-delete
- 3 migrations applied to pg-forge-01 (Identity, Chat, Catalog)

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-02-25 20:35:35 -05:00
co-authored by Claude Happy
parent 348c37b9b5
commit 4663003dd7
40 changed files with 2494 additions and 1 deletions
@@ -75,6 +75,12 @@ public sealed class CatalogDbContext : DbContext
e.HasIndex(c => c.Rarity);
e.HasIndex(c => new { c.IsPublished, c.SetId });
// Incremental sync cursor — clients page through cards ordered by this value.
// Default 0 is overridden by a Postgres trigger on every INSERT/UPDATE.
e.Property(c => c.DefinitionVersion)
.HasDefaultValue(0L);
e.HasIndex(c => c.DefinitionVersion);
// Self-reference: Tier N ArchSpirit → Tier (N-1) ArchSpirit.
e.HasOne(c => c.PreviousTier)
.WithMany()
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
using SOR.Database.Entities.Chat;
using SOR.Database.Enums;
/// <summary>
/// EF Core DbContext for the chat schema.
/// At scale, high-frequency chat messages may be offloaded to a time-series store;
@@ -26,6 +27,8 @@ public sealed class ChatDbContext : DbContext
public DbSet<ChatMessage> Messages => Set<ChatMessage>();
public DbSet<FriendRequest> FriendRequests => Set<FriendRequest>();
public DbSet<BlockedUser> BlockedUsers => Set<BlockedUser>();
public DbSet<AccountPresence> AccountPresences => Set<AccountPresence>();
public DbSet<Notification> Notifications => Set<Notification>();
protected override void OnModelCreating(ModelBuilder builder)
{
@@ -83,5 +86,22 @@ public sealed class ChatDbContext : DbContext
e.HasIndex(b => new { b.BlockerAccountId, b.BlockedAccountId }).IsUnique();
e.HasIndex(b => b.BlockerAccountId);
});
builder.Entity<AccountPresence>(e =>
{
e.ToTable("account_presence");
// One row per account — AccountId is both PK and the cross-schema FK.
e.HasKey(p => p.AccountId);
e.Property(p => p.Status).HasConversion<string>();
});
builder.Entity<Notification>(e =>
{
e.ToTable("notifications");
e.HasKey(n => n.Id);
e.Property(n => n.PayloadJson).HasColumnType("jsonb").HasColumnName("payload");
// Primary query: unread notifications for a recipient, newest first.
e.HasIndex(n => new { n.RecipientAccountId, n.ReadAt, n.CreatedAt });
});
}
}
@@ -26,6 +26,7 @@ public sealed class SorIdentityDbContext
public DbSet<AccountSession> AccountSessions => Set<AccountSession>();
public DbSet<AccountProperty> AccountProperties => Set<AccountProperty>();
public DbSet<ClientRelease> ClientReleases => Set<ClientRelease>();
protected override void OnModelCreating(ModelBuilder builder)
{
@@ -66,5 +67,13 @@ public sealed class SorIdentityDbContext
e.HasIndex(p => new { p.AccountId, p.Key }).IsUnique();
e.HasIndex(p => p.AccountId);
});
builder.Entity<ClientRelease>(e =>
{
e.ToTable("client_releases");
e.HasKey(r => r.Id);
// Fast lookup: find latest active release for a platform.
e.HasIndex(r => new { r.Platform, r.IsActive, r.ReleasedAt });
});
}
}
@@ -89,9 +89,24 @@ public sealed class CardDefinition
/// <summary>Only published cards are visible in the client and available for collection.</summary>
public bool IsPublished { get; set; }
/// <summary>
/// Soft-deleted cards remain in the catalog so clients can purge them from local cache.
/// Retired cards are excluded from new collection grants, booster draws, and shop listings.
/// </summary>
public bool IsRetired { get; set; }
public DateTimeOffset? RetiredAt { get; set; }
public DateTimeOffset CreatedAt { get; set; }
public DateTimeOffset UpdatedAt { get; set; }
/// <summary>
/// Monotonic version counter assigned by a Postgres trigger on every INSERT or UPDATE.
/// Clients use this as a cursor for incremental catalog sync:
/// fetch WHERE DefinitionVersion > lastKnownVersion ORDER BY DefinitionVersion ASC LIMIT N.
/// </summary>
public long DefinitionVersion { get; set; }
// ── Navigation ───────────────────────────────────────────────────────────
public CardSet? Set { get; set; }
public ICollection<CardAsset> Assets { get; set; } = new List<CardAsset>();
@@ -0,0 +1,24 @@
namespace SOR.Database.Entities.Chat;
using SOR.Database.Enums;
/// <summary>
/// Tracks the real-time presence status of an account.
/// One row per account; upserted when the client calls chat.presence.set.
/// </summary>
public sealed class AccountPresence
{
/// <summary>PK and FK cross-schema to identity.accounts.</summary>
public Guid AccountId { get; set; }
public PresenceStatus Status { get; set; }
/// <summary>Populated when Status == InMatch; null otherwise.</summary>
public Guid? CurrentMatchId { get; set; }
/// <summary>When this presence record was last changed.</summary>
public DateTimeOffset UpdatedAt { get; set; }
/// <summary>Last time the account was seen online (even if now Away/Offline).</summary>
public DateTimeOffset LastSeenAt { get; set; }
}
@@ -0,0 +1,34 @@
namespace SOR.Database.Entities.Chat;
/// <summary>
/// An in-app notification for a specific account.
/// Delivered over the existing WebSocket connection; persisted so the client can
/// fetch missed notifications on reconnect.
///
/// Well-known NotificationType values:
/// "outbid" — another player placed a higher bid on your auction
/// "friend_request" — incoming friend request
/// "friend_accept" — your friend request was accepted
/// "match_invite" — challenged to a match
/// </summary>
public sealed class Notification
{
public Guid Id { get; set; } = Guid.NewGuid();
/// <summary>Cross-schema: identity.accounts.Id of the recipient.</summary>
public Guid RecipientAccountId { get; set; }
/// <summary>Well-known type string used by the client to choose how to render the notification.</summary>
public string NotificationType { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
/// <summary>JSONB: type-specific payload (e.g. listingId for outbid, requesterId for friend_request).</summary>
public string? PayloadJson { get; set; }
public DateTimeOffset CreatedAt { get; set; }
/// <summary>Null = unread. Set when the client calls chat.notifications.read.</summary>
public DateTimeOffset? ReadAt { get; set; }
}
@@ -0,0 +1,31 @@
namespace SOR.Database.Entities.Identity;
/// <summary>
/// Represents a published client release for a given platform.
/// Used by the version check service to inform clients whether an update is available
/// or required before they can play.
/// </summary>
public sealed class ClientRelease
{
public Guid Id { get; set; } = Guid.NewGuid();
/// <summary>Platform identifier: "android", "ios", "pc", "web".</summary>
public string Platform { get; set; } = string.Empty;
/// <summary>Semantic version string, e.g. "1.2.3".</summary>
public string Version { get; set; } = string.Empty;
/// <summary>If true, clients on any older version must update before playing.</summary>
public bool IsRequired { get; set; }
/// <summary>Direct download or store URL for this release.</summary>
public string? DownloadUrl { get; set; }
/// <summary>Human-readable release notes shown in the update prompt.</summary>
public string? ReleaseNotes { get; set; }
/// <summary>Inactive releases are ignored by the version check.</summary>
public bool IsActive { get; set; }
public DateTimeOffset ReleasedAt { get; set; }
}
@@ -20,3 +20,11 @@ public enum FriendRequestStatus
Accepted,
Declined,
}
public enum PresenceStatus
{
Online,
InMatch,
Away,
Offline,
}
@@ -0,0 +1,334 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SOR.Database.Contexts;
#nullable disable
namespace SOR.Database.Migrations.Catalog
{
[DbContext(typeof(CatalogDbContext))]
[Migration("20260226012910_AddDefinitionVersionAndRetired")]
partial class AddDefinitionVersionAndRetired
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("catalog")
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ActionName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AnimationCdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("CardDefinitionId", "ActionName")
.IsUnique();
b.ToTable("card_animation_bindings", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AssetType")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("CdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.Property<string>("MimeType")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardDefinitionId", "AssetType");
b.ToTable("card_assets", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AbilitiesJson")
.HasColumnType("jsonb")
.HasColumnName("abilities");
b.Property<string>("Affinity")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AttackType")
.HasColumnType("text");
b.Property<bool?>("CanAttack")
.HasColumnType("boolean");
b.Property<bool?>("CanBeAttacked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeBlocked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeObstructed")
.HasColumnType("boolean");
b.Property<bool?>("CanBeSacrificed")
.HasColumnType("boolean");
b.Property<bool?>("CanDefend")
.HasColumnType("boolean");
b.Property<bool?>("CanMove")
.HasColumnType("boolean");
b.Property<bool?>("CanUseAbility")
.HasColumnType("boolean");
b.Property<string>("CardType")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("CollectorNumber")
.HasColumnType("integer");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("Damage")
.HasColumnType("integer");
b.Property<long>("DefinitionVersion")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasDefaultValue(0L);
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EffectsJson")
.HasColumnType("jsonb")
.HasColumnName("effects");
b.Property<string[]>("Genus")
.HasColumnType("text[]");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<bool>("IsRetired")
.HasColumnType("boolean");
b.Property<int?>("MaxAttackRange")
.HasColumnType("integer");
b.Property<int?>("MaxChannelRange")
.HasColumnType("integer");
b.Property<int?>("MaxDefense")
.HasColumnType("integer");
b.Property<int?>("MaxHealth")
.HasColumnType("integer");
b.Property<int?>("MinAttackRange")
.HasColumnType("integer");
b.Property<int?>("MinChannelRange")
.HasColumnType("integer");
b.Property<int?>("MovementPoints")
.HasColumnType("integer");
b.Property<string>("MovementType")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OtherCostsJson")
.HasColumnType("jsonb")
.HasColumnName("other_costs");
b.Property<Guid?>("PreviousTierId")
.HasColumnType("uuid");
b.Property<string>("Rarity")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("RequiresLos")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("RetiredAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("SetId")
.HasColumnType("uuid");
b.Property<int>("SpCost")
.HasColumnType("integer");
b.Property<int>("StCost")
.HasColumnType("integer");
b.Property<string>("TerramorphaMode")
.HasColumnType("text");
b.Property<int?>("Tier")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Affinity");
b.HasIndex("CardType");
b.HasIndex("DefinitionVersion");
b.HasIndex("Name");
b.HasIndex("PreviousTierId");
b.HasIndex("Rarity");
b.HasIndex("SetId");
b.HasIndex("IsPublished", "SetId");
b.ToTable("card_definitions", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateOnly?>("ReleaseDate")
.HasColumnType("date");
b.HasKey("Id");
b.HasIndex("Code")
.IsUnique();
b.ToTable("card_sets", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition")
.WithMany("AnimationBindings")
.HasForeignKey("CardDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CardDefinition");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition")
.WithMany("Assets")
.HasForeignKey("CardDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CardDefinition");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "PreviousTier")
.WithMany()
.HasForeignKey("PreviousTierId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("SOR.Database.Entities.Catalog.CardSet", "Set")
.WithMany("Cards")
.HasForeignKey("SetId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("PreviousTier");
b.Navigation("Set");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.Navigation("AnimationBindings");
b.Navigation("Assets");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b =>
{
b.Navigation("Cards");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,93 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Catalog
{
/// <inheritdoc />
public partial class AddDefinitionVersionAndRetired : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "DefinitionVersion",
schema: "catalog",
table: "card_definitions",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<bool>(
name: "IsRetired",
schema: "catalog",
table: "card_definitions",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTimeOffset>(
name: "RetiredAt",
schema: "catalog",
table: "card_definitions",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_card_definitions_DefinitionVersion",
schema: "catalog",
table: "card_definitions",
column: "DefinitionVersion");
// Postgres sequence + trigger: every INSERT or UPDATE automatically advances
// DefinitionVersion, giving clients a monotonic cursor for incremental sync.
migrationBuilder.Sql("""
CREATE SEQUENCE IF NOT EXISTS catalog.card_definition_version_seq
START 1 INCREMENT 1;
CREATE OR REPLACE FUNCTION catalog.set_definition_version()
RETURNS TRIGGER AS $$
BEGIN
NEW."DefinitionVersion" := nextval('catalog.card_definition_version_seq');
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trg_card_definitions_version
BEFORE INSERT OR UPDATE ON catalog.card_definitions
FOR EACH ROW EXECUTE FUNCTION catalog.set_definition_version();
""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("""
DROP TRIGGER IF EXISTS trg_card_definitions_version ON catalog.card_definitions;
DROP FUNCTION IF EXISTS catalog.set_definition_version();
DROP SEQUENCE IF EXISTS catalog.card_definition_version_seq;
""");
migrationBuilder.DropIndex(
name: "IX_card_definitions_DefinitionVersion",
schema: "catalog",
table: "card_definitions");
migrationBuilder.DropColumn(
name: "DefinitionVersion",
schema: "catalog",
table: "card_definitions");
migrationBuilder.DropColumn(
name: "IsRetired",
schema: "catalog",
table: "card_definitions");
migrationBuilder.DropColumn(
name: "RetiredAt",
schema: "catalog",
table: "card_definitions");
}
}
}
@@ -138,6 +138,11 @@ namespace SOR.Database.Migrations.Catalog
b.Property<int?>("Damage")
.HasColumnType("integer");
b.Property<long>("DefinitionVersion")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasDefaultValue(0L);
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
@@ -152,6 +157,9 @@ namespace SOR.Database.Migrations.Catalog
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<bool>("IsRetired")
.HasColumnType("boolean");
b.Property<int?>("MaxAttackRange")
.HasColumnType("integer");
@@ -194,6 +202,9 @@ namespace SOR.Database.Migrations.Catalog
b.Property<bool?>("RequiresLos")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("RetiredAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("SetId")
.HasColumnType("uuid");
@@ -218,6 +229,8 @@ namespace SOR.Database.Migrations.Catalog
b.HasIndex("CardType");
b.HasIndex("DefinitionVersion");
b.HasIndex("Name");
b.HasIndex("PreviousTierId");
@@ -0,0 +1,272 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SOR.Database.Contexts;
#nullable disable
namespace SOR.Database.Migrations.Chat
{
[DbContext(typeof(ChatDbContext))]
[Migration("20260226012908_AddPresenceAndNotifications")]
partial class AddPresenceAndNotifications
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("chat")
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SOR.Database.Entities.Chat.AccountPresence", b =>
{
b.Property<Guid>("AccountId")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("CurrentMatchId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("LastSeenAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("AccountId");
b.ToTable("account_presence", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.BlockedUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("BlockedAccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("BlockedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("BlockerAccountId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("BlockerAccountId");
b.HasIndex("BlockerAccountId", "BlockedAccountId")
.IsUnique();
b.ToTable("blocked_users", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.ChatChannel", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ChannelType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("MatchId")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ChannelType");
b.HasIndex("MatchId");
b.ToTable("channels", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMember", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<Guid>("ChannelId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("JoinedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("LeftAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("AccountId");
b.HasIndex("ChannelId", "AccountId")
.IsUnique();
b.ToTable("members", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMessage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ChannelId")
.HasColumnType("uuid");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("EditedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<Guid>("SenderAccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("SentAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("SenderAccountId");
b.HasIndex("ChannelId", "SentAt");
b.ToTable("messages", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.FriendRequest", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("RecipientAccountId")
.HasColumnType("uuid");
b.Property<Guid>("RequesterAccountId")
.HasColumnType("uuid");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("RecipientAccountId");
b.HasIndex("Status");
b.HasIndex("RequesterAccountId", "RecipientAccountId")
.IsUnique();
b.ToTable("friend_requests", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.Notification", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Body")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("NotificationType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PayloadJson")
.HasColumnType("jsonb")
.HasColumnName("payload");
b.Property<DateTimeOffset?>("ReadAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("RecipientAccountId")
.HasColumnType("uuid");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RecipientAccountId", "ReadAt", "CreatedAt");
b.ToTable("notifications", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMember", b =>
{
b.HasOne("SOR.Database.Entities.Chat.ChatChannel", "Channel")
.WithMany("Members")
.HasForeignKey("ChannelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Channel");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMessage", b =>
{
b.HasOne("SOR.Database.Entities.Chat.ChatChannel", "Channel")
.WithMany("Messages")
.HasForeignKey("ChannelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Channel");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.ChatChannel", b =>
{
b.Navigation("Members");
b.Navigation("Messages");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,68 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Chat
{
/// <inheritdoc />
public partial class AddPresenceAndNotifications : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "account_presence",
schema: "chat",
columns: table => new
{
AccountId = table.Column<Guid>(type: "uuid", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
CurrentMatchId = table.Column<Guid>(type: "uuid", nullable: true),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
LastSeenAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_account_presence", x => x.AccountId);
});
migrationBuilder.CreateTable(
name: "notifications",
schema: "chat",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
RecipientAccountId = table.Column<Guid>(type: "uuid", nullable: false),
NotificationType = table.Column<string>(type: "text", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Body = table.Column<string>(type: "text", nullable: false),
payload = table.Column<string>(type: "jsonb", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
ReadAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_notifications", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_notifications_RecipientAccountId_ReadAt_CreatedAt",
schema: "chat",
table: "notifications",
columns: new[] { "RecipientAccountId", "ReadAt", "CreatedAt" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "account_presence",
schema: "chat");
migrationBuilder.DropTable(
name: "notifications",
schema: "chat");
}
}
}
@@ -23,6 +23,30 @@ namespace SOR.Database.Migrations.Chat
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SOR.Database.Entities.Chat.AccountPresence", b =>
{
b.Property<Guid>("AccountId")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("CurrentMatchId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("LastSeenAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("AccountId");
b.ToTable("account_presence", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.BlockedUser", b =>
{
b.Property<Guid>("Id")
@@ -173,6 +197,44 @@ namespace SOR.Database.Migrations.Chat
b.ToTable("friend_requests", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.Notification", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Body")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("NotificationType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PayloadJson")
.HasColumnType("jsonb")
.HasColumnName("payload");
b.Property<DateTimeOffset?>("ReadAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("RecipientAccountId")
.HasColumnType("uuid");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RecipientAccountId", "ReadAt", "CreatedAt");
b.ToTable("notifications", "chat");
});
modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMember", b =>
{
b.HasOne("SOR.Database.Entities.Chat.ChatChannel", "Channel")
@@ -0,0 +1,407 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SOR.Database.Contexts;
#nullable disable
namespace SOR.Database.Migrations.Identity
{
[DbContext(typeof(SorIdentityDbContext))]
[Migration("20260226012858_AddClientReleases")]
partial class AddClientReleases
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("identity")
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("roles", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("role_claims", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("account_claims", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("external_logins", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("account_roles", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("account_tokens", "identity");
});
modelBuilder.Entity("SOR.Database.Entities.Identity.Account", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("AvatarCdnUrl")
.HasColumnType("text");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DisplayName")
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LastLoginAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<int>("OriginPoints")
.HasColumnType("integer");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<DateTimeOffset?>("StarterDeckSelectedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("DisplayName");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("accounts", "identity");
});
modelBuilder.Entity("SOR.Database.Entities.Identity.AccountProperty", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("AccountId");
b.HasIndex("AccountId", "Key")
.IsUnique();
b.ToTable("account_properties", "identity");
});
modelBuilder.Entity("SOR.Database.Entities.Identity.AccountSession", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeviceId")
.HasColumnType("text");
b.Property<DateTimeOffset>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("IpAddress")
.HasColumnType("text");
b.Property<DateTimeOffset?>("RevokedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("TokenHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UserAgent")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TokenHash")
.IsUnique();
b.HasIndex("AccountId", "ExpiresAt");
b.ToTable("account_sessions", "identity");
});
modelBuilder.Entity("SOR.Database.Entities.Identity.ClientRelease", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("DownloadUrl")
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsRequired")
.HasColumnType("boolean");
b.Property<string>("Platform")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ReleaseNotes")
.HasColumnType("text");
b.Property<DateTimeOffset>("ReleasedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Version")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Platform", "IsActive", "ReleasedAt");
b.ToTable("client_releases", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,48 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Identity
{
/// <inheritdoc />
public partial class AddClientReleases : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "client_releases",
schema: "identity",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Platform = table.Column<string>(type: "text", nullable: false),
Version = table.Column<string>(type: "text", nullable: false),
IsRequired = table.Column<bool>(type: "boolean", nullable: false),
DownloadUrl = table.Column<string>(type: "text", nullable: true),
ReleaseNotes = table.Column<string>(type: "text", nullable: true),
IsActive = table.Column<bool>(type: "boolean", nullable: false),
ReleasedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_client_releases", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_client_releases_Platform_IsActive_ReleasedAt",
schema: "identity",
table: "client_releases",
columns: new[] { "Platform", "IsActive", "ReleasedAt" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "client_releases",
schema: "identity");
}
}
}
@@ -312,6 +312,42 @@ namespace SOR.Database.Migrations.Identity
b.ToTable("account_sessions", "identity");
});
modelBuilder.Entity("SOR.Database.Entities.Identity.ClientRelease", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("DownloadUrl")
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsRequired")
.HasColumnType("boolean");
b.Property<string>("Platform")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ReleaseNotes")
.HasColumnType("text");
b.Property<DateTimeOffset>("ReleasedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Version")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Platform", "IsActive", "ReleasedAt");
b.ToTable("client_releases", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)