Files
DorkNet/DorkNet.Server/Migrations/20260728061658_ClubPermissionsGalleryAndModeration.cs
Alexa cf3aa29ba2 fix: address the 15 CodeRabbit findings from the wire-audit review
Security:
- roomcode PUT now requires instance ownership (any player could plant
  or relocate codes on foreign private instances)
- /platformid/{accountId} requires auth (anonymous Steam/Oculus id
  enumeration oracle)
- request tracing no longer captures successful /thread bodies by
  default (chat messages landed unredacted in logs); opt in via
  Trace__SuccessBodyPaths
- anonymous action-link renewal clamped to 720h per consume

Data integrity:
- buyPurchaseReminder upserts its objective sentinel (second purchase
  threw UNIQUE after the wallet was debited)
- progression reward gift + idempotency sentinel commit in one
  transaction (crash between them double-minted the reward)
- ClubPermissionsGalleryAndModeration migration defaults corrected to
  the entity contract (CommentsJson '[]', ClubChatEnabled true); new
  one-shot ClubChatDefaultRepair migration fixes databases that
  applied the wrong defaults; bootstrap repairs '' CommentsJson rows
- admin subroom-maxplayers audit entry commits with the mutation
- account purge covers CustomAvatarItems (ownership deleted, created
  items reassigned to the system account)
- duplicate photo reports ignored while one is unresolved

Stability:
- bootstrap only swallows the expected duplicate-column error; locked
  databases and schema failures now fail startup instead of the first
  endpoint
- clone blob write failure degrades to an empty sub-room instead of a
  500 after the clone row committed
- resumed photo-feed cursor stamped DateTimeKind.Utc (Npgsql rejects
  Unspecified for timestamptz)
- unreadcounts queries per requested room instead of materialising the
  whole comment keyspace

Tests:
- destroys-the-probe-session template guard is case-insensitive

74/74 tests pass.
2026-08-02 01:16:38 +03:00

125 lines
4.9 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DorkNet.Server.Migrations
{
/// <inheritdoc />
public partial class ClubPermissionsGalleryAndModeration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// Defaults must match the entity contract (TestCaseEntity inits
// CommentsJson to "[]", ClubEntity inits ClubChatEnabled to true):
// existing rows get the column default, and "" is not valid JSON
// while false silently muted every pre-existing club's chat. The
// ClubChatDefaultRepair migration fixes databases that applied
// this migration before the defaults were corrected.
migrationBuilder.AddColumn<string>(
name: "CommentsJson",
table: "TestCases",
type: "TEXT",
nullable: false,
defaultValue: "[]");
migrationBuilder.AddColumn<bool>(
name: "ClubChatEnabled",
table: "Clubs",
type: "INTEGER",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn<int>(
name: "MinLevel",
table: "Clubs",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "ModerationState",
table: "ChatMessages",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "ClubAdditionalImages",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ClubId = table.Column<long>(type: "INTEGER", nullable: false),
Slot = table.Column<int>(type: "INTEGER", nullable: false),
ImageName = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClubAdditionalImages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ClubRolePermissions",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ClubId = table.Column<long>(type: "INTEGER", nullable: false),
MembershipType = table.Column<int>(type: "INTEGER", nullable: false),
EditDetails = table.Column<bool>(type: "INTEGER", nullable: false),
ApproveMember = table.Column<bool>(type: "INTEGER", nullable: false),
CreateEvent = table.Column<bool>(type: "INTEGER", nullable: false),
PostAnnouncement = table.Column<bool>(type: "INTEGER", nullable: false),
EditPermissionSettings = table.Column<bool>(type: "INTEGER", nullable: false),
BanUnban = table.Column<bool>(type: "INTEGER", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClubRolePermissions", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_ClubAdditionalImages_ClubId_Slot",
table: "ClubAdditionalImages",
columns: new[] { "ClubId", "Slot" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ClubRolePermissions_ClubId_MembershipType",
table: "ClubRolePermissions",
columns: new[] { "ClubId", "MembershipType" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ClubAdditionalImages");
migrationBuilder.DropTable(
name: "ClubRolePermissions");
migrationBuilder.DropColumn(
name: "CommentsJson",
table: "TestCases");
migrationBuilder.DropColumn(
name: "ClubChatEnabled",
table: "Clubs");
migrationBuilder.DropColumn(
name: "MinLevel",
table: "Clubs");
migrationBuilder.DropColumn(
name: "ModerationState",
table: "ChatMessages");
}
}
}