Files
discord-rpg-concept/shared/db/DrizzleClient.ts

18 lines
629 B
TypeScript

import { drizzle } from "drizzle-orm/postgres-js";
import postgresJs from "postgres"; // Renamed import
import * as schema from "./schema";
import { env } from "@shared/lib/env";
const connectionString = env.DATABASE_URL;
// Disable prefetch to prevent connection handling issues in serverless/container environments
const client = postgresJs(connectionString, { prepare: false });
export const DrizzleClient = drizzle(client, { schema });
// Export the raw client as 'postgres' to match previous Bun.SQL export name/usage
export const postgres = client;
export const closeDatabase = async () => {
await client.end();
};