Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Database: Case counting system change
Browse files Browse the repository at this point in the history
The old system, under extreme race conditions can bug out and produce 2 cases with the same case id (not global case id).

Here, we change it to instead count the cases, as for case removal we have a removed field.

A unique constraint is also implemented in ModerationCase as a extra-measure
  • Loading branch information
RadiatedExodus committed Feb 16, 2024
1 parent 9ace265 commit f4c833f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ model Guild {
JoinLeaveLogChannelId String @default("")
PublicModLogChannelId String @default("")
LoggingChannelId String @default("")
CurrentCaseId Int @default(0)
BanAppealLink String @default("")
ModerationCase ModerationCase[]
Tag Tag[]
Expand Down Expand Up @@ -49,6 +48,8 @@ model ModerationCase {
CreatedAt DateTime @default(now())
ActiveTempBans ActiveTempBans[]
ModerationCaseHistory ModerationCaseHistory[]
@@unique(name: "UniqueCaseIdPerGuild", fields: [GuildId, CaseId])
}

model ModerationCaseHistory {
Expand All @@ -63,6 +64,7 @@ model ModerationCaseHistory {
ModeratorNote String?
ModeratorAttachment String?
NotAppealable Boolean?
Removed Boolean?
}

model ActiveTempBans {
Expand Down

0 comments on commit f4c833f

Please sign in to comment.