import { drizzle } from 'drizzle-orm/postgres-js' import postgres from 'postgres' import * as schema from './schema' const connectionString = process.env.DATABASE_URL ?? 'postgres://wc:wc@localhost:5432/worldcup' // DB_PASSWORD is passed separately to avoid URL-encoding issues with special chars // (e.g. #, ], = in passwords break URL parsing). Falls back to password in DATABASE_URL for local dev. const client = postgres(connectionString, { max: 10, ...(process.env.DB_PASSWORD ? { password: process.env.DB_PASSWORD } : {}), }) export const db = drizzle(client, { schema }) export * from './schema'