- Added a `warningNumber` field to the `Warning` model for sequential identification of warnings. - Updated the `createWarning` function to handle the new `warningNumber` logic and notify users via DM upon receiving a warning. - Refactored moderation commands to utilize the new warning system, including changes to the warning creation and removal processes. - Enhanced the WebUI to display warning numbers in the warnings table and updated localization for related messages. - Documented changes in phase tracking to reflect the new warning system features.
17 lines
523 B
SQL
17 lines
523 B
SQL
-- AlterTable
|
|
ALTER TABLE "Warning" ADD COLUMN "warningNumber" INTEGER;
|
|
|
|
-- Backfill per-guild sequential numbers (oldest first)
|
|
WITH numbered AS (
|
|
SELECT id, ROW_NUMBER() OVER (PARTITION BY "guildId" ORDER BY "createdAt" ASC, id ASC) AS rn
|
|
FROM "Warning"
|
|
)
|
|
UPDATE "Warning" AS w
|
|
SET "warningNumber" = numbered.rn
|
|
FROM numbered
|
|
WHERE w.id = numbered.id;
|
|
|
|
ALTER TABLE "Warning" ALTER COLUMN "warningNumber" SET NOT NULL;
|
|
|
|
CREATE UNIQUE INDEX "Warning_guildId_warningNumber_key" ON "Warning"("guildId", "warningNumber");
|