File tree Expand file tree Collapse file tree
migrations/20251101170231_add_moderation_tables Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ -- CreateTable
2+ CREATE TABLE "ModerationAction " (
3+ " id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
4+ " type" TEXT NOT NULL ,
5+ " status" TEXT NOT NULL DEFAULT ' ACTIVE' ,
6+ " reason" TEXT ,
7+ " duration" INTEGER ,
8+ " targetId" INTEGER NOT NULL ,
9+ " moderatorId" INTEGER NOT NULL ,
10+ " createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ,
11+ " expiresAt" DATETIME,
12+ " parentActionId" INTEGER ,
13+ CONSTRAINT " ModerationAction_targetId_fkey" FOREIGN KEY (" targetId" ) REFERENCES " User" (" id" ) ON DELETE RESTRICT ON UPDATE CASCADE,
14+ CONSTRAINT " ModerationAction_moderatorId_fkey" FOREIGN KEY (" moderatorId" ) REFERENCES " User" (" id" ) ON DELETE RESTRICT ON UPDATE CASCADE,
15+ CONSTRAINT " ModerationAction_parentActionId_fkey" FOREIGN KEY (" parentActionId" ) REFERENCES " ModerationAction" (" id" ) ON DELETE SET NULL ON UPDATE CASCADE
16+ );
17+
18+ -- CreateIndex
19+ CREATE INDEX "ModerationAction_targetId_idx " ON " ModerationAction" (" targetId" );
20+
21+ -- CreateIndex
22+ CREATE INDEX "ModerationAction_moderatorId_idx " ON " ModerationAction" (" moderatorId" );
23+
24+ -- CreateIndex
25+ CREATE INDEX "ModerationAction_status_idx " ON " ModerationAction" (" status" );
26+
27+ -- CreateIndex
28+ CREATE INDEX "ModerationAction_createdAt_idx " ON " ModerationAction" (" createdAt" );
29+
30+ -- CreateIndex
31+ CREATE INDEX "User_discordId_idx " ON " User" (" discordId" );
Original file line number Diff line number Diff line change 22// learn more about it in the docs: https://pris.ly/d/prisma-schema
33
44generator client {
5- provider = " prisma-client "
5+ provider = " prisma-client-js "
66 output = " ../generated/prisma "
77}
88
99datasource db {
1010 provider = " sqlite "
11- url = " file:./dev .db "
11+ url = " file:../data/moderation .db "
1212}
1313
1414model User {
15- id Int @id @default (autoincrement () )
16- discordId String @unique
15+ id Int @id @default (autoincrement () )
16+ discordId String @unique
17+
18+ // Relations
19+ actionsReceived ModerationAction [] @relation (" ActionTarget " )
20+ actionsPerformed ModerationAction [] @relation (" ActionModerator " )
21+
22+ @@index ([discordId ] )
23+ }
24+
25+ enum ActionType {
26+ WARN
27+ MUTE
28+ UNMUTE
29+ KICK
30+ BAN
31+ UNBAN
32+ TIMEOUT
33+ REMOVE_TIMEOUT
34+ REPEL
35+ }
36+
37+ enum ActionStatus {
38+ ACTIVE
39+ EXPIRED
40+ REMOVED_BY_ERROR
41+ REVERSED
42+ }
43+
44+ model ModerationAction {
45+ id Int @id @default (autoincrement () )
46+ type ActionType
47+ status ActionStatus @default (ACTIVE )
48+ reason String ?
49+ duration Int ? // Duration in seconds for timeouts/mutes
50+
51+ // User relationships
52+ targetId Int
53+ target User @relation (" ActionTarget " , fields : [targetId ] , references : [id ] )
54+ moderatorId Int
55+ moderator User @relation (" ActionModerator " , fields : [moderatorId ] , references : [id ] )
56+
57+ // Timestamps
58+ createdAt DateTime @default (now () )
59+ expiresAt DateTime ?
60+
61+ // For corrections/reversals
62+ parentActionId Int ?
63+ parentAction ModerationAction ? @relation (" ActionCorrections " , fields : [parentActionId ] , references : [id ] )
64+ corrections ModerationAction [] @relation (" ActionCorrections " )
65+
66+ @@index ([targetId ] )
67+ @@index ([moderatorId ] )
68+ @@index ([status ] )
69+ @@index ([createdAt ] )
1770}
You can’t perform that action at this time.
0 commit comments