Discord Permissions will be revoked, when under a penalty

This commit is contained in:
PxlLoewe
2026-01-31 22:48:26 +01:00
parent d1c49a3208
commit ac441e908d
7 changed files with 94 additions and 40 deletions

View File

@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Penalty" ADD COLUMN "addPermissionApplied" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN "removePermissionApplied" BOOLEAN NOT NULL DEFAULT false;

View File

@@ -0,0 +1,13 @@
/*
Warnings:
- The primary key for the `FormerDiscordAccount` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- DropIndex
DROP INDEX "FormerDiscordAccount_discord_id_key";
-- AlterTable
ALTER TABLE "FormerDiscordAccount" DROP CONSTRAINT "FormerDiscordAccount_pkey",
ADD COLUMN "id" SERIAL NOT NULL,
ADD CONSTRAINT "FormerDiscordAccount_pkey" PRIMARY KEY ("id");

View File

@@ -10,6 +10,10 @@ model Penalty {
suspended Boolean @default(false)
// For Chronjob to know if permissions were already applied/removed
removePermissionApplied Boolean @default(false)
addPermissionApplied Boolean @default(false)
timestamp DateTime @default(now())
// relations:

View File

@@ -94,14 +94,13 @@ model User {
}
model FormerDiscordAccount {
discordId String @unique @map(name: "discord_id")
id Int @id @default(autoincrement())
discordId String @map(name: "discord_id")
userId String @map(name: "user_id")
removedAt DateTime @default(now()) @map(name: "removed_at")
DiscordAccount DiscordAccount? @relation(fields: [discordId], references: [discordId], onDelete: SetNull)
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([discordId, userId])
}
model DiscordAccount {
@@ -119,9 +118,9 @@ model DiscordAccount {
updatedAt DateTime @default(now()) @map(name: "updated_at")
// Related User
userId String? @unique
User User? @relation(fields: [userId], references: [id], onDelete: SetNull)
formerDiscordAccount FormerDiscordAccount?
userId String? @unique
User User? @relation(fields: [userId], references: [id], onDelete: SetNull)
formerDiscordAccount FormerDiscordAccount[]
@@map(name: "discord_accounts")
}