From fde816da8d06f1e1ed9b2e28a30731401e0a01b8 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sun, 27 Jul 2025 21:16:43 +0200 Subject: [PATCH] Fix --- app/profiles/page.tsx | 6 +++--- lib/db-utils.ts | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/profiles/page.tsx b/app/profiles/page.tsx index 78b3c0bf..e5f6abf1 100644 --- a/app/profiles/page.tsx +++ b/app/profiles/page.tsx @@ -1,7 +1,7 @@ import {redirect} from "next/navigation"; import Link from "next/link"; import { prisma }from "@/lib/prisma"; -import {checkPostTableExists} from "@/lib/db-utils"; +import {checkUserTableExists} from "@/lib/db-utils"; // Disable static generation @@ -10,7 +10,7 @@ export const dynamic = "force-dynamic"; export default async function PostsPage() { // Check if the post table exists - const tableExists = await checkPostTableExists(); + const tableExists = await checkUserTableExists(); // If the post table doesn't exist, redirect to setup page if (!tableExists) { @@ -21,7 +21,7 @@ export default async function PostsPage() { orderBy: { createdAt: "desc", }, - take: 6, + // take: 20, // include: { // author: { // select: { diff --git a/lib/db-utils.ts b/lib/db-utils.ts index 7ec367b4..0b401845 100644 --- a/lib/db-utils.ts +++ b/lib/db-utils.ts @@ -1,15 +1,11 @@ "use server"; -import { prisma }from "@/lib/prisma"; +import {prisma} from "@/lib/prisma"; -/** - * Checks if the Post table exists in the database - * @returns Promise - true if the table exists, false otherwise - */ -export async function checkPostTableExists(): Promise { + +export async function checkUserTableExists(): Promise { try { - // Try to query the post table - await prisma.post.findFirst(); + await prisma.user.findFirst(); return true; } catch { // If there's an error, the table likely doesn't exist