import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; import * as schema from "./schema"; // Points at pgCat/PgBouncer, not Postgres directly, so keep prepared // statements disabled and cap the pool per-instance connections low. const connectionString = process.env.DATABASE_URL; if (!connectionString) { throw new Error("DATABASE_URL is not set"); } const client = postgres(connectionString, { prepare: false, max: Number(process.env.DATABASE_POOL_MAX ?? 10), }); export const db = drizzle(client, { schema }); export type Database = typeof db;