Defer database client creation until first use via Proxy so Next.js builds succeed without POSTGRES_URL and SUPABASE_URL env vars present. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 lines
318 B
TypeScript
12 lines
318 B
TypeScript
import { drizzle } from 'drizzle-orm/postgres-js'
|
|
import postgres from 'postgres'
|
|
import * as schema from './schema'
|
|
|
|
const connectionString = process.env.POSTGRES_URL ?? ''
|
|
|
|
const client = postgres(connectionString, { prepare: false })
|
|
|
|
export const db = drizzle({ client, schema })
|
|
|
|
export type Database = typeof db
|