Add chat service, collection clone/tier rules, social graph
SOR.Chat (new project):
- 10 WebSocket message handlers: send, get_channels, get_messages,
dm_open, friend_request, friend_respond, friend_remove, block,
unblock, get_social
- Cursor-based pagination for message history
- Block checks on DM send and dm_open
- Social graph: friends / pending requests (in+out) / blocked list
- Batch identity DB lookups for display names
Collection updates:
- clone_deck handler (copy deck + re-validate)
- Tier-chain validation: deck ArchSpirit must be Tier 1 (hard rule);
warn on Tier 2+ card without previous tier present (soft warning)
- Tier 2+ ArchSpirits now allowed in card list as ascension targets
- ValidationWarnings field added to DeckSummaryDto + DeckDetailDto
Database:
- CardDefinition.PreviousTierId self-reference FK for ascension chains
- FriendRequest + BlockedUser entities in chat schema
- ChatChannelType.System + FriendRequestStatus enum values
- Migrations: AddArchSpiritTierChain (catalog), AddSocialGraph (chat)
Admin portal:
- ChatOverview (/chat) — stats + channel list with type filter
- ChatChannelViewer (/chat/channel/{id}) — message history + system
message compose for admins
- SocialModerationPage (/chat/social) — friend/block lookup + actions
- NavMenu: Chat section with Social Graph sub-item
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:
@@ -75,6 +75,13 @@ public sealed class CatalogDbContext : DbContext
|
||||
e.HasIndex(c => c.Rarity);
|
||||
e.HasIndex(c => new { c.IsPublished, c.SetId });
|
||||
|
||||
// Self-reference: Tier N ArchSpirit → Tier (N-1) ArchSpirit.
|
||||
e.HasOne(c => c.PreviousTier)
|
||||
.WithMany()
|
||||
.HasForeignKey(c => c.PreviousTierId)
|
||||
.IsRequired(false)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
e.HasMany(c => c.Assets)
|
||||
.WithOne(a => a.CardDefinition)
|
||||
.HasForeignKey(a => a.CardDefinitionId)
|
||||
|
||||
@@ -24,6 +24,8 @@ public sealed class ChatDbContext : DbContext
|
||||
public DbSet<ChatChannel> Channels => Set<ChatChannel>();
|
||||
public DbSet<ChatMember> Members => Set<ChatMember>();
|
||||
public DbSet<ChatMessage> Messages => Set<ChatMessage>();
|
||||
public DbSet<FriendRequest> FriendRequests => Set<FriendRequest>();
|
||||
public DbSet<BlockedUser> BlockedUsers => Set<BlockedUser>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
@@ -61,5 +63,25 @@ public sealed class ChatDbContext : DbContext
|
||||
e.HasIndex(m => new { m.ChannelId, m.SentAt });
|
||||
e.HasIndex(m => m.SenderAccountId);
|
||||
});
|
||||
|
||||
builder.Entity<FriendRequest>(e =>
|
||||
{
|
||||
e.ToTable("friend_requests");
|
||||
e.HasKey(f => f.Id);
|
||||
e.Property(f => f.Status).HasConversion<string>();
|
||||
// Unique pair regardless of who initiated: enforced at service layer
|
||||
// (two players can't have duplicate relationships).
|
||||
e.HasIndex(f => new { f.RequesterAccountId, f.RecipientAccountId }).IsUnique();
|
||||
e.HasIndex(f => f.RecipientAccountId);
|
||||
e.HasIndex(f => f.Status);
|
||||
});
|
||||
|
||||
builder.Entity<BlockedUser>(e =>
|
||||
{
|
||||
e.ToTable("blocked_users");
|
||||
e.HasKey(b => b.Id);
|
||||
e.HasIndex(b => new { b.BlockerAccountId, b.BlockedAccountId }).IsUnique();
|
||||
e.HasIndex(b => b.BlockerAccountId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,16 @@ public sealed class CardDefinition
|
||||
/// <summary>Tier 1 = base form; higher tiers reached via Ascend/Transition.</summary>
|
||||
public int? Tier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For Tier 2+ ArchSpirits: the Tier (N-1) card this ascends from.
|
||||
/// Null for Tier 1 and all non-ArchSpirit cards.
|
||||
/// Used to validate ascension chains in deck construction.
|
||||
/// </summary>
|
||||
public Guid? PreviousTierId { get; set; }
|
||||
|
||||
/// <summary>Navigation for the ascension chain (self-reference within catalog).</summary>
|
||||
public CardDefinition? PreviousTier { get; set; }
|
||||
|
||||
// ── Terramorpha-only ────────────────────────────────────────────────────
|
||||
public TerramorphaMode? TerramorphaMode { get; set; }
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace SOR.Database.Entities.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// Records that one player has blocked another.
|
||||
///
|
||||
/// Effects of blocking:
|
||||
/// - Blocker cannot receive DMs from the blocked player.
|
||||
/// - Blocked player cannot send DMs to the blocker.
|
||||
/// - Existing friendship (if any) is dissolved when a block is created.
|
||||
/// - Blocked player cannot send friend requests to the blocker.
|
||||
///
|
||||
/// Cross-schema: both Guids have no EF FK to identity.accounts.
|
||||
/// </summary>
|
||||
public sealed class BlockedUser
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
/// <summary>The player who performed the block.</summary>
|
||||
public Guid BlockerAccountId { get; set; }
|
||||
|
||||
/// <summary>The player who was blocked.</summary>
|
||||
public Guid BlockedAccountId { get; set; }
|
||||
|
||||
public DateTimeOffset BlockedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace SOR.Database.Entities.Chat;
|
||||
|
||||
using SOR.Database.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// A friend request from one player to another.
|
||||
///
|
||||
/// Once accepted, the row stays with Status = Accepted — this is the
|
||||
/// canonical record of friendship. To check if two players are friends:
|
||||
/// SELECT 1 FROM chat.friend_requests
|
||||
/// WHERE ((requester = A AND recipient = B) OR (requester = B AND recipient = A))
|
||||
/// AND status = 'Accepted'
|
||||
///
|
||||
/// Declined requests are kept for spam-prevention (prevents immediate re-request).
|
||||
/// A player can re-request after the existing declined row is cleared by TTL/admin.
|
||||
///
|
||||
/// Cross-schema: both Guids have no EF FK to identity.accounts.
|
||||
/// </summary>
|
||||
public sealed class FriendRequest
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public Guid RequesterAccountId { get; set; }
|
||||
public Guid RecipientAccountId { get; set; }
|
||||
|
||||
public FriendRequestStatus Status { get; set; } = FriendRequestStatus.Pending;
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -10,4 +10,13 @@ public enum ChatChannelType
|
||||
Direct,
|
||||
/// <summary>Guild/clan channel.</summary>
|
||||
Guild,
|
||||
/// <summary>Admin-only broadcast channel for system announcements.</summary>
|
||||
System,
|
||||
}
|
||||
|
||||
public enum FriendRequestStatus
|
||||
{
|
||||
Pending,
|
||||
Accepted,
|
||||
Declined,
|
||||
}
|
||||
|
||||
Generated
+315
@@ -0,0 +1,315 @@
|
||||
// <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("20260225174746_AddArchSpiritTierChain")]
|
||||
partial class AddArchSpiritTierChain
|
||||
{
|
||||
/// <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.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<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<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<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<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("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,57 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SOR.Database.Migrations.Catalog
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddArchSpiritTierChain : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "PreviousTierId",
|
||||
schema: "catalog",
|
||||
table: "card_definitions",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_card_definitions_PreviousTierId",
|
||||
schema: "catalog",
|
||||
table: "card_definitions",
|
||||
column: "PreviousTierId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_card_definitions_card_definitions_PreviousTierId",
|
||||
schema: "catalog",
|
||||
table: "card_definitions",
|
||||
column: "PreviousTierId",
|
||||
principalSchema: "catalog",
|
||||
principalTable: "card_definitions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_card_definitions_card_definitions_PreviousTierId",
|
||||
schema: "catalog",
|
||||
table: "card_definitions");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_card_definitions_PreviousTierId",
|
||||
schema: "catalog",
|
||||
table: "card_definitions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PreviousTierId",
|
||||
schema: "catalog",
|
||||
table: "card_definitions");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,6 +178,9 @@ namespace SOR.Database.Migrations.Catalog
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("other_costs");
|
||||
|
||||
b.Property<Guid?>("PreviousTierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Rarity")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@@ -211,6 +214,8 @@ namespace SOR.Database.Migrations.Catalog
|
||||
|
||||
b.HasIndex("Name");
|
||||
|
||||
b.HasIndex("PreviousTierId");
|
||||
|
||||
b.HasIndex("Rarity");
|
||||
|
||||
b.HasIndex("SetId");
|
||||
@@ -275,11 +280,18 @@ namespace SOR.Database.Migrations.Catalog
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
// <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("20260225174846_AddSocialGraph")]
|
||||
partial class AddSocialGraph
|
||||
{
|
||||
/// <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.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.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,91 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SOR.Database.Migrations.Chat
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddSocialGraph : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "blocked_users",
|
||||
schema: "chat",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
BlockerAccountId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
BlockedAccountId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
BlockedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_blocked_users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "friend_requests",
|
||||
schema: "chat",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
RequesterAccountId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
RecipientAccountId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Status = table.Column<string>(type: "text", nullable: false),
|
||||
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_friend_requests", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_blocked_users_BlockerAccountId",
|
||||
schema: "chat",
|
||||
table: "blocked_users",
|
||||
column: "BlockerAccountId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_blocked_users_BlockerAccountId_BlockedAccountId",
|
||||
schema: "chat",
|
||||
table: "blocked_users",
|
||||
columns: new[] { "BlockerAccountId", "BlockedAccountId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_friend_requests_RecipientAccountId",
|
||||
schema: "chat",
|
||||
table: "friend_requests",
|
||||
column: "RecipientAccountId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_friend_requests_RequesterAccountId_RecipientAccountId",
|
||||
schema: "chat",
|
||||
table: "friend_requests",
|
||||
columns: new[] { "RequesterAccountId", "RecipientAccountId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_friend_requests_Status",
|
||||
schema: "chat",
|
||||
table: "friend_requests",
|
||||
column: "Status");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "blocked_users",
|
||||
schema: "chat");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "friend_requests",
|
||||
schema: "chat");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,31 @@ namespace SOR.Database.Migrations.Chat
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
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")
|
||||
@@ -114,6 +139,40 @@ namespace SOR.Database.Migrations.Chat
|
||||
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.ChatMember", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Chat.ChatChannel", "Channel")
|
||||
|
||||
Reference in New Issue
Block a user