fix: add server_name to moderation_actions for full context retention

Denormalize guild name alongside username so the moderation dashboard
shows both TARGET and server even after message table purges.
Migration 0018. Frontend displays 'username · server_name' in TARGET.
This commit is contained in:
asepharyana
2026-08-27 12:32:12 +07:00
parent cccfd89266
commit 0de393625f
10 changed files with 30 additions and 2 deletions
@@ -643,6 +643,7 @@ export const pgModerationActionsTable = pgTable(
evidence: pgText("evidence"), // JSON array of short quoted snippets
policy_version: pgText("policy_version"), // rules.ts policy version string
username: pgText("username"), // denormalized from messages table for retention safety
server_name: pgText("server_name"), // denormalized guild name for retention safety
},
(table) => ({
messageIdIdx: pgIndex("idx_moderation_actions_message_id").on(
@@ -60,6 +60,7 @@ export const pgModerationActionsTable = pgTable(
evidence: pgText("evidence"), // JSON array of short quoted snippets
policy_version: pgText("policy_version"), // rules.ts policy version string
username: pgText("username"), // denormalized from messages table for retention safety
server_name: pgText("server_name"), // denormalized guild name for retention safety
},
(table) => ({
messageIdIdx: pgIndex("idx_moderation_actions_message_id").on(
@@ -209,6 +209,7 @@ export interface ModerationAction {
action_type: ModerationActionType;
reason: string | null;
username: string | null;
server_name: string | null;
executed_by: string | null;
status: "pending" | "executed" | "failed";
error: string | null;