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

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-08-01 14:15:12 +02:00
1 parent 53b350057d
commit 7c39aef5d9
40 files changed
+1124 -692

No files matched your search

+11 -11
View File
@@ -1,6 +1,7 @@
import { asc, eq, inArray } from "drizzle-orm";
import { getTranslations } from "next-intl/server";
import { ContentCard, EmptyState } from "@/components/public/ui";
import { prisma } from "@/lib/prisma";
import { db, RadioSchedules, User } from "@/lib/db";
export const revalidate = 300;
@@ -35,21 +36,20 @@ type Slot = {
export default async function RadioSchedulePage() {
const t = await getTranslations("pages.radioSchedule");
const schedules = await prisma.radioSchedules
.findMany({
where: { isActive: true },
orderBy: { startTime: "asc" },
})
const schedules = await db
.select()
.from(RadioSchedules)
.where(eq(RadioSchedules.isActive, true))
.orderBy(asc(RadioSchedules.startTime))
.catch(() => []);
// Resolve DJ usernames. schedule.userId is BigInt; User.id is Int — convert.
const djIds = Array.from(new Set(schedules.map((s) => Number(s.userId))));
const djs = djIds.length
? await prisma.user
.findMany({
where: { id: { in: djIds } },
select: { id: true, username: true },
})
? await db
.select({ id: User.id, username: User.username })
.from(User)
.where(inArray(User.id, djIds))
.catch(() => [])
: [];
const djById = new Map(djs.map((u) => [u.id, u.username]));