import { defineConfig } from "prisma/config"; // Load env for Prisma CLI in local development. // In production (Docker/Coolify), env vars are injected by the platform, so we avoid a hard // dependency on `dotenv` in the runtime image. try { // eslint-disable-next-line @typescript-eslint/no-require-imports const dotenv = require("dotenv") as typeof import("dotenv"); dotenv.config({ path: ".env.local" }); dotenv.config(); } catch { // `dotenv` is optional at runtime; safe to ignore. } // Migrations MUST use a direct Postgres connection (prefer DIRECT_URL). // During Docker build, these env vars may be absent, so we provide a placeholder // to allow `prisma generate` / Next build to proceed. const MIGRATE_URL = process.env.DIRECT_URL ?? process.env.RUNTIME_DATABASE_URL ?? process.env.DATABASE_URL ?? // Placeholder only (build-time / local-only). Real deployments MUST provide DATABASE_URL/DIRECT_URL. "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"; export default defineConfig({ schema: "prisma/schema.prisma", // This is the only datasource URL Prisma Migrate will use in Prisma 7 datasource: { url: MIGRATE_URL, // Optional, only if you use a shadow DB for migrations: // shadowDatabaseUrl: process.env.SHADOW_DATABASE_URL, }, migrations: { path: "prisma/migrations", seed: "tsx prisma/seed.ts", }, });