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

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-08-01 14:15:28 +02:00
1 parent 7c39aef5d9
commit 2cd0863cb8
40 files changed
+1069 -726

No files matched your search

+10 -8
View File
@@ -1,3 +1,4 @@
import { desc, eq, gt, or } from "drizzle-orm";
import { Ban } from "lucide-react";
import { redirect } from "next/navigation";
import { getTranslations } from "next-intl/server";
@@ -5,10 +6,10 @@ import { createBan, liftBan } from "@/actions/admin-bans";
import { AdminPageShell } from "@/components/admin/admin-page-shell";
import { StatusCard } from "@/components/admin/dashboard";
import { Button } from "@/components/ui/button";
import { activeBanWhere, unixNow } from "@/lib/bans";
import { unixNow } from "@/lib/bans";
import { Ban as BanTable, db } from "@/lib/db";
import { formatDate } from "@/lib/format-date";
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
import { prisma } from "@/lib/prisma";
export default async function AdminBans() {
const { session, permissions } = await getAdminContext();
@@ -18,13 +19,14 @@ export default async function AdminBans() {
const t = await getTranslations("pages.admin.bans");
const now = unixNow();
let bans: Awaited<ReturnType<typeof prisma.ban.findMany>> = [];
let bans: (typeof BanTable.$inferSelect)[] = [];
try {
bans = await prisma.ban.findMany({
where: activeBanWhere(now),
orderBy: { timestamp: "desc" },
take: 100,
});
bans = await db
.select()
.from(BanTable)
.where(or(eq(BanTable.banExpire, 0), gt(BanTable.banExpire, now)))
.orderBy(desc(BanTable.timestamp))
.limit(100);
} catch {
bans = [];
}