fix: store username on moderation_actions for retention safety

Add denormalized  column to moderation_actions so the
dashboard TARGET field survives message table purges. Backfills all
existing 217 rows. Changes: schema + autoDeleteManager + backend
repository query + migration 0017.
This commit is contained in:
asepharyana
2026-08-27 12:15:06 +07:00
parent 17aad2cc39
commit cccfd89266
8 changed files with 24 additions and 2 deletions
@@ -0,0 +1,9 @@
ALTER TABLE "moderation_actions" ADD COLUMN "username" text;
--> statement-breakpoint
-- Backfill username from messages table for existing actions
UPDATE "moderation_actions" a
SET "username" = m."username"
FROM "messages" m
WHERE a."message_id" = m."id"
AND a."username" IS NULL
AND m."username" IS NOT NULL;
@@ -120,6 +120,13 @@
"when": 1787185000000,
"tag": "0016_drop_user_reputations",
"breakpoints": true
},
{
"idx": 17,
"version": "7",
"when": 1787810000000,
"tag": "0017_add_username_to_moderation_actions",
"breakpoints": true
}
]
}