feat: reimplement punishments

This commit is contained in:
trafficlunar 2026-04-21 13:22:46 +01:00
parent 7bd84ea454
commit 77828653ba
34 changed files with 1229 additions and 1068 deletions

View file

@ -0,0 +1,25 @@
/*
Warnings:
- You are about to drop the column `punishmentId` on the `miis` table. All the data in the column will be lost.
- You are about to drop the column `notes` on the `punishments` table. All the data in the column will be lost.
- You are about to drop the column `reasons` on the `punishments` table. All the data in the column will be lost.
- You are about to drop the `mii_punishments` table. If the table is not empty, all the data it contains will be lost.
- Added the required column `reason` to the `punishments` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "mii_punishments" DROP CONSTRAINT "mii_punishments_miiId_fkey";
-- DropForeignKey
ALTER TABLE "mii_punishments" DROP CONSTRAINT "mii_punishments_punishmentId_fkey";
-- AlterTable
ALTER TABLE "miis" DROP COLUMN "punishmentId";
-- AlterTable
ALTER TABLE "punishments" RENAME COLUMN "notes" TO "reason";
ALTER TABLE "punishments" DROP COLUMN "reasons";
-- DropTable
DROP TABLE "mii_punishments";

View file

@ -90,12 +90,9 @@ model Mii {
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
likeCount Int @default(0)
punishmentId Int?
punishments MiiPunishment[]
likedBy Like[]
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
likeCount Int @default(0)
likedBy Like[]
@@index([tags], type: Gin)
@@index([createdAt])
@ -142,28 +139,13 @@ model Report {
@@map("reports")
}
model MiiPunishment {
punishmentId Int
miiId Int
reason String
punishment Punishment @relation(fields: [punishmentId], references: [id], onDelete: Cascade)
mii Mii @relation(fields: [miiId], references: [id], onDelete: Cascade)
@@id([punishmentId, miiId])
@@map("mii_punishments")
}
model Punishment {
id Int @id @default(autoincrement())
userId Int
type PunishmentType
returned Boolean @default(false)
notes String
reasons String[]
violatingMiis MiiPunishment[]
reason String
expiresAt DateTime?
createdAt DateTime @default(now())