From aa631095faaf262a2be359b0d1790599abca685a Mon Sep 17 00:00:00 2001
From: trafficlunar
Date: Wed, 22 Apr 2026 11:45:54 +0100
Subject: [PATCH] fix: parity with vite-split
idk what to use
---
.../migration.sql | 2 -
.../migration.sql | 25 ++++++++++++
prisma/schema.prisma | 26 ++----------
src/app/admin/page.tsx | 9 -----
src/app/api/admin/lookup/route.ts | 11 +----
src/app/api/admin/punish/route.ts | 22 ++--------
src/app/api/return/route.ts | 11 -----
src/app/off-the-island/page.tsx | 40 +------------------
src/components/admin/user-management.tsx | 28 ++-----------
9 files changed, 37 insertions(+), 137 deletions(-)
create mode 100644 prisma/migrations/20260421113133_useless_punishment_fields/migration.sql
diff --git a/prisma/migrations/20260419170916_use_like_count/migration.sql b/prisma/migrations/20260419170916_use_like_count/migration.sql
index 65a4df0..cfd9eac 100644
--- a/prisma/migrations/20260419170916_use_like_count/migration.sql
+++ b/prisma/migrations/20260419170916_use_like_count/migration.sql
@@ -3,5 +3,3 @@ ALTER TABLE "miis" ADD COLUMN "likeCount" INTEGER NOT NULL DEFAULT 0;
-- CreateIndex
CREATE INDEX "miis_likeCount_idx" ON "miis"("likeCount" DESC);
-
-UPDATE miis SET "likeCount" = (SELECT COUNT(*) FROM likes WHERE likes."miiId" = miis.id);
diff --git a/prisma/migrations/20260421113133_useless_punishment_fields/migration.sql b/prisma/migrations/20260421113133_useless_punishment_fields/migration.sql
new file mode 100644
index 0000000..e7d52ac
--- /dev/null
+++ b/prisma/migrations/20260421113133_useless_punishment_fields/migration.sql
@@ -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";
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index dca9d42..041eb4e 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -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())
diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx
index b0ef785..d0abb00 100644
--- a/src/app/admin/page.tsx
+++ b/src/app/admin/page.tsx
@@ -43,15 +43,6 @@ export default async function AdminPage({ searchParams }: Props) {
-
- {/* Separator */}
-
-
- Control Center
-
-
-
-
{/* Separator */}
diff --git a/src/app/api/admin/lookup/route.ts b/src/app/api/admin/lookup/route.ts
index 350cedb..02d5179 100644
--- a/src/app/api/admin/lookup/route.ts
+++ b/src/app/api/admin/lookup/route.ts
@@ -29,16 +29,7 @@ export async function GET(request: NextRequest) {
id: true,
type: true,
returned: true,
-
- notes: true,
- reasons: true,
- violatingMiis: {
- select: {
- miiId: true,
- reason: true,
- },
- },
-
+ reason: true,
expiresAt: true,
createdAt: true,
},
diff --git a/src/app/api/admin/punish/route.ts b/src/app/api/admin/punish/route.ts
index c341973..e49d3fb 100644
--- a/src/app/api/admin/punish/route.ts
+++ b/src/app/api/admin/punish/route.ts
@@ -14,16 +14,7 @@ const punishSchema = z.object({
.number({ error: "Duration (days) must be a number" })
.int({ error: "Duration (days) must be an integer" })
.positive({ error: "Duration (days) must be valid" }),
- notes: z.string(),
- reasons: z.array(z.string()).optional(),
- miiReasons: z
- .array(
- z.object({
- id: z.number({ error: "Mii ID must be a number" }).int({ error: "Mii ID must be an integer" }).positive({ error: "Mii ID must be valid" }),
- reason: z.string(),
- }),
- )
- .optional(),
+ reason: z.string(),
});
export async function POST(request: NextRequest) {
@@ -42,7 +33,7 @@ export async function POST(request: NextRequest) {
const parsed = punishSchema.safeParse(body);
if (!parsed.success) return NextResponse.json({ error: parsed.error.issues[0].message }, { status: 400 });
- const { type, duration, notes, reasons, miiReasons } = parsed.data;
+ const { type, duration, reason } = parsed.data;
const expiresAt = type === "TEMP_EXILE" ? dayjs().add(duration, "days").toDate() : null;
@@ -51,14 +42,7 @@ export async function POST(request: NextRequest) {
userId,
type: type as PunishmentType,
expiresAt,
- notes,
- reasons: reasons?.length !== 0 ? reasons : [],
- violatingMiis: {
- create: miiReasons?.map((mii) => ({
- miiId: mii.id,
- reason: mii.reason,
- })),
- },
+ reason,
},
});
diff --git a/src/app/api/return/route.ts b/src/app/api/return/route.ts
index 6da81b6..cb1c601 100644
--- a/src/app/api/return/route.ts
+++ b/src/app/api/return/route.ts
@@ -17,17 +17,6 @@ export async function DELETE(request: NextRequest) {
userId: Number(session.user?.id),
returned: false,
},
- include: {
- violatingMiis: {
- include: {
- mii: {
- select: {
- name: true,
- },
- },
- },
- },
- },
});
if (!activePunishment) return rateLimit.sendResponse({ error: "You have no active punishments!" }, 404);
diff --git a/src/app/off-the-island/page.tsx b/src/app/off-the-island/page.tsx
index d44f77a..727b7bf 100644
--- a/src/app/off-the-island/page.tsx
+++ b/src/app/off-the-island/page.tsx
@@ -29,17 +29,6 @@ export default async function ExiledPage() {
userId: Number(session?.user.id),
returned: false,
},
- include: {
- violatingMiis: {
- include: {
- mii: {
- select: {
- name: true,
- },
- },
- },
- },
- },
});
if (!activePunishment) redirect("/");
@@ -74,36 +63,9 @@ export default async function ExiledPage() {
- Note: {activePunishment.notes}
+ Reason: {activePunishment.reason}
-
-
- Violating Items
-
-
-
-
- {activePunishment.reasons.map((index, reason) => (
-
- ))}
- {activePunishment.violatingMiis.map((mii) => (
-
-
-
-
{mii.mii.name}
-
- Reason: {mii.reason}
-
-
-
- ))}
-
-
{activePunishment.type !== "PERM_EXILE" ? (
diff --git a/src/components/admin/user-management.tsx b/src/components/admin/user-management.tsx
index 3734640..6b9c9bf 100644
--- a/src/components/admin/user-management.tsx
+++ b/src/components/admin/user-management.tsx
@@ -5,7 +5,7 @@
import { useState } from "react";
import { Icon } from "@iconify/react";
-import { Prisma, PunishmentType } from "@prisma/client";
+import { Prisma, Punishment, PunishmentType } from "@prisma/client";
import ProfilePicture from "../profile-picture";
import SubmitButton from "../submit-button";
@@ -16,11 +16,7 @@ interface ApiResponse {
name: string;
image: string;
createdAt: string;
- punishments: Prisma.PunishmentGetPayload<{
- include: {
- violatingMiis: true;
- };
- }>[];
+ punishments: Punishment[];
}
interface MiiList {
@@ -170,7 +166,7 @@ export default function Punishments() {
- Notes: {punishment.notes}
+ Reason: {punishment.reason}
{punishment.type !== "WARNING" && (
@@ -185,24 +181,6 @@ export default function Punishments() {
Returned: {JSON.stringify(punishment.returned)}
)}
-
- Reasons:
-
-
- {punishment.reasons.map((reason, index) => (
- - {reason}
- ))}
-
-
- Mii Reasons:
-
-
- {punishment.violatingMiis.map((mii) => (
- -
- {mii.miiId}: {mii.reason}
-
- ))}
-
))}
>