import { existsSync } from "node:fs"; import { defineConfig } from "drizzle-kit"; // drizzle-kit (unlike the Next.js app) does not load .env automatically, so // DATABASE_URL would be undefined and fall back to the wrong host. Load .env // for local dev. In production the env is already provided (docker-compose) // and no .env file exists, so this is skipped. if (!process.env.DATABASE_URL && existsSync(".env")) { process.loadEnvFile(".env"); } export default defineConfig({ schema: "./lib/db/schema.ts", out: "./lib/db/migrations", dialect: "postgresql", dbCredentials: { url: process.env.DATABASE_URL ?? "postgresql://postgres:postgres@localhost:5432/moh_sass", }, });