refactor(db): migrate app pages and APIs from Prisma facade to Drizzle (3)

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-08-01 14:15:32 +02:00
1 parent 2cd0863cb8
commit 580972c0a0
40 files changed
+1089 -808

No files matched your search

+39 -33
View File
@@ -1,9 +1,10 @@
import { desc } from "drizzle-orm";
import { getTranslations } from "next-intl/server";
import { deleteShout } from "@/actions/admin-radio-moderation";
import { StatusCard } from "@/components/admin/dashboard";
import { Button } from "@/components/ui/button";
import { db, RadioApplications, RadioSchedules, RadioShouts } from "@/lib/db";
import { formatDate } from "@/lib/format-date";
import { prisma } from "@/lib/prisma";
type Shout = {
id: bigint;
@@ -52,48 +53,53 @@ export default async function AdminRadioPage() {
let schedules: Schedule[] = [];
try {
shouts = await prisma.radioShouts.findMany({
select: { id: true, userId: true, message: true, createdAt: true },
orderBy: { id: "desc" },
take: 25,
});
shouts = await db
.select({
id: RadioShouts.id,
userId: RadioShouts.userId,
message: RadioShouts.message,
createdAt: RadioShouts.createdAt,
})
.from(RadioShouts)
.orderBy(desc(RadioShouts.id))
.limit(25);
} catch {
shouts = [];
}
try {
applications = await prisma.radioApplications.findMany({
select: {
id: true,
userId: true,
realName: true,
age: true,
status: true,
musicStyle: true,
discordUsername: true,
createdAt: true,
},
orderBy: { id: "desc" },
take: 25,
});
applications = await db
.select({
id: RadioApplications.id,
userId: RadioApplications.userId,
realName: RadioApplications.realName,
age: RadioApplications.age,
status: RadioApplications.status,
musicStyle: RadioApplications.musicStyle,
discordUsername: RadioApplications.discordUsername,
createdAt: RadioApplications.createdAt,
})
.from(RadioApplications)
.orderBy(desc(RadioApplications.id))
.limit(25);
} catch {
applications = [];
}
try {
schedules = await prisma.radioSchedules.findMany({
select: {
id: true,
userId: true,
day: true,
startTime: true,
endTime: true,
showName: true,
isActive: true,
},
orderBy: { id: "desc" },
take: 25,
});
schedules = await db
.select({
id: RadioSchedules.id,
userId: RadioSchedules.userId,
day: RadioSchedules.day,
startTime: RadioSchedules.startTime,
endTime: RadioSchedules.endTime,
showName: RadioSchedules.showName,
isActive: RadioSchedules.isActive,
})
.from(RadioSchedules)
.orderBy(desc(RadioSchedules.id))
.limit(25);
} catch {
schedules = [];
}