mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-11 16:49:28 -04:00
Fix
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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<boolean> - true if the table exists, false otherwise
|
||||
*/
|
||||
export async function checkPostTableExists(): Promise<boolean> {
|
||||
|
||||
export async function checkUserTableExists(): Promise<boolean> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user