Using db. causes the whole app to hang forever.

drizzle.config.ts
import type { Config } from "drizzle-kit"

import "dotenv/config"

export default {
schema: "./src/lib/db/schema.ts",
driver: "mysql2",
out: "./src/drizzle/migrations",
dbCredentials: {
connectionString: process.env.DATABASE_URL!,
},
} satisfies Config
import type { Config } from "drizzle-kit"

import "dotenv/config"

export default {
schema: "./src/lib/db/schema.ts",
driver: "mysql2",
out: "./src/drizzle/migrations",
dbCredentials: {
connectionString: process.env.DATABASE_URL!,
},
} satisfies Config
index.ts
import { connect } from "@planetscale/database"
import { drizzle } from "drizzle-orm/planetscale-serverless"


import * as schema from "@/lib/db/schema"

import "dotenv/config"

const connection = connect({
url: process.env.DATABASE_URL,
})

export const db = drizzle(connection, { schema })

export const getFeedbacks = async ({ query }: { query?: string }) => {...
}
import { connect } from "@planetscale/database"
import { drizzle } from "drizzle-orm/planetscale-serverless"


import * as schema from "@/lib/db/schema"

import "dotenv/config"

const connection = connect({
url: process.env.DATABASE_URL,
})

export const db = drizzle(connection, { schema })

export const getFeedbacks = async ({ query }: { query?: string }) => {...
}
layout.tsx
import "./globals.css"

import { db } from "@/lib/db"
import { users } from "@/lib/db/schema"

export const metadata = {...
}

export default async function RootLayout({
children,
authModal,
}: {
children: React.ReactNode
authModal: React.ReactNode
}) {

const data = await db.query.users.findMany()
console.log(data)
return (
<html lang="en">...
</html>
)
}
import "./globals.css"

import { db } from "@/lib/db"
import { users } from "@/lib/db/schema"

export const metadata = {...
}

export default async function RootLayout({
children,
authModal,
}: {
children: React.ReactNode
authModal: React.ReactNode
}) {

const data = await db.query.users.findMany()
console.log(data)
return (
<html lang="en">...
</html>
)
}
I can successfully db:push, and I can see the tables being created on planetscale as well as when running db:studio
1 Reply
PWSey
PWSeyOP13mo ago
It was because of getFeedbacks, moving that function to another file fixed it for some reason
Want results from more Discord servers?
Add your server