24f9a69022
Backend - Add ClipSubmission entity + table (runtime bootstrapper) and POST /api/public/clips (server-derives platform from the link) - Surface clip submissions in the admin season detail - Add DELETE candidate/category/clip endpoints with audit entries Frontend - Clips admin: real moderation view (list, open link, delete) instead of placeholder; wired clipSubmissions through types/api/store - Categories admin: add delete with confirm modal (matches Candidates) - Voting ranking bar uses the unified purple gradient - Fix ASCII transliterations to proper German umlauts across admin - Remove orphan AdminView 2.vue Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
71 lines
3.1 KiB
C#
71 lines
3.1 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Backend.Data;
|
|
|
|
public static class OperationalTablesBootstrapper
|
|
{
|
|
public static Task EnsureAsync(AwardsDbContext db) =>
|
|
db.Database.ExecuteSqlRawAsync(
|
|
"""
|
|
ALTER TABLE "UserSessions"
|
|
ADD COLUMN IF NOT EXISTS "CreatedFromIp" character varying(80) NOT NULL DEFAULT '';
|
|
|
|
ALTER TABLE "UserSessions"
|
|
ADD COLUMN IF NOT EXISTS "UserAgent" character varying(400) NOT NULL DEFAULT '';
|
|
|
|
CREATE TABLE IF NOT EXISTS "RiskFlags" (
|
|
"Id" integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
"SeasonId" integer NULL,
|
|
"TwitchUserId" character varying(120) NULL,
|
|
"Source" character varying(80) NOT NULL,
|
|
"Type" character varying(80) NOT NULL,
|
|
"Severity" character varying(20) NOT NULL,
|
|
"Status" character varying(20) NOT NULL,
|
|
"Summary" character varying(240) NOT NULL,
|
|
"CreatedFromIp" character varying(80) NOT NULL,
|
|
"UserAgent" character varying(400) NOT NULL,
|
|
"MetadataJson" text NOT NULL,
|
|
"ReviewedByTwitchId" character varying(120) NULL,
|
|
"CreatedAt" timestamp with time zone NOT NULL,
|
|
"ReviewedAt" timestamp with time zone NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "IX_RiskFlags_Status_CreatedAt"
|
|
ON "RiskFlags" ("Status", "CreatedAt" DESC);
|
|
|
|
CREATE INDEX IF NOT EXISTS "IX_RiskFlags_SeasonId"
|
|
ON "RiskFlags" ("SeasonId");
|
|
|
|
CREATE TABLE IF NOT EXISTS "AdminAuditEntries" (
|
|
"Id" integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
"AdminTwitchUserId" character varying(120) NOT NULL,
|
|
"ActionType" character varying(80) NOT NULL,
|
|
"EntityType" character varying(80) NOT NULL,
|
|
"EntityId" character varying(120) NOT NULL,
|
|
"Summary" character varying(240) NOT NULL,
|
|
"MetadataJson" text NOT NULL,
|
|
"CreatedAt" timestamp with time zone NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "IX_AdminAuditEntries_CreatedAt"
|
|
ON "AdminAuditEntries" ("CreatedAt" DESC);
|
|
|
|
CREATE TABLE IF NOT EXISTS "ClipSubmissions" (
|
|
"Id" integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
"SeasonId" integer NOT NULL,
|
|
"CategoryId" integer NULL,
|
|
"SubmittedByTwitchId" character varying(120) NOT NULL,
|
|
"ClipUrl" character varying(500) NOT NULL,
|
|
"Title" character varying(200) NOT NULL,
|
|
"Creator" character varying(120) NOT NULL,
|
|
"Platform" character varying(40) NOT NULL,
|
|
"Status" character varying(20) NOT NULL,
|
|
"CreatedFromIp" character varying(80) NOT NULL,
|
|
"CreatedAt" timestamp with time zone NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "IX_ClipSubmissions_SeasonId_Status"
|
|
ON "ClipSubmissions" ("SeasonId", "Status");
|
|
""");
|
|
}
|