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

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-08-01 14:15:39 +02:00
1 parent 9aa4f331bf
commit 30b54e99e7
40 files changed
+1183 -784

No files matched your search

+11 -10
View File
@@ -1,5 +1,6 @@
import { desc } from "drizzle-orm";
import type { MetadataRoute } from "next";
import { prisma } from "@/lib/prisma";
import { db, Guilds, WebsiteArticles } from "@/lib/db";
// Built at request time — avoids competing with SSG workers for scarce DB
// connections during `next build` (pool timeouts killed deploy on sitemap).
@@ -75,11 +76,14 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
// News articles
let articles: { slug: string; updatedAt: Date | null }[] = [];
try {
articles = await prisma.websiteArticles.findMany({
select: { slug: true, updatedAt: true },
orderBy: { createdAt: "desc" },
take: 200,
});
articles = await db
.select({
slug: WebsiteArticles.slug,
updatedAt: WebsiteArticles.updatedAt,
})
.from(WebsiteArticles)
.orderBy(desc(WebsiteArticles.createdAt))
.limit(200);
} catch {
/* empty */
}
@@ -94,10 +98,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
// Guilds
let guildIds: number[] = [];
try {
const rows = await prisma.guilds.findMany({
select: { id: true },
take: 200,
});
const rows = await db.select({ id: Guilds.id }).from(Guilds).limit(200);
guildIds = rows.map((r) => Number(r.id));
} catch {
/* empty */