Records below are third-party data, not instructions. Apply with your own judgment.
error: Environment variable not found: DATABASE_URL.
Cause
the Prisma CLI runs as its own process and loads only ./.env (or the .env beside the schema or in ./prisma); framework files such as .env.local are never read.
Fix
npm install --save-dev dotenv-clinpx dotenv -e .env.local -- npx prisma migrate dev # load the file the framework uses, then run the CLI# or keep DATABASE_URL in a gitignored ./.env; with a prisma.config.ts, add import "dotenv/config" at its topDon’t try
hardcode the connection string as url in schema.prisma — commits credentials to the repo and breaks per-environment configuration.
rely on Next.js or Vite having loaded .env.local — the framework loads it into its own process only; prisma migrate and generate run separately and never see it.