Next.js Discord

Discord Forum

Prisma Not Seeing Db URL Env Var

Unanswered
VoidPointer posted this in #help-forum
Open in Discord
I'm just checking here because I've followed 2 guides for setting up Prisma, and with both I get a fail on the first migrate, so maybe it's a me and Nextjs issue, not Prisma. This prisma.comfig.ts:
import "dotenv/config";
import { defineConfig } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  migrations: {
    path: "prisma/migrations",
  },
  datasource: {
    url: process.env["DATABASE_URL"],
  },
});

And the .env file generated by prisma init:
# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add `import "dotenv/config";` to your `prisma.config.ts` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="file:./dev.db"

Yet when I run pnpm dlx prisma migrate dev --name init, I get this error:
Loaded Prisma config from prisma.config.ts.

Prisma schema loaded from prisma\schema.prisma.
Datasource "db": SQLite database

Error: P1013: The provided database string is invalid. The scheme is not recognized in database URL. Please refer to the documentation in https://pris.ly/d/config-url for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.

If I hard code the url it works.

0 Replies