Prisma doesn't see .env.development

Hi! I want to seperate my dev and prod env on my NextJS project. NextJS follow this rule by default, next dev use .env.development and next build use .env or .env.production. But Prisma doesn't follow this rule. When I want to migrate/generate prisma-client on my test env, that DB URLs located at .env.development, Prisma always use .env, and tries to connect prod database. My package.json file scripts look like that:
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"vercel-build": "prisma generate && prisma migrate deploy && next build",
"migrate:dev": "dotenv -e .env.development -- pnpx prisma migrate dev"
}
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"vercel-build": "prisma generate && prisma migrate deploy && next build",
"migrate:dev": "dotenv -e .env.development -- pnpx prisma migrate dev"
}
But I get error P1013 when I try to run migrate:dev script. How can I solve this? - Tried to rename .env -> .env.production. - Installed dotenv-cli and dotenv that said on Prisma docs. My Postgresql DB sits on Docker. Prisma was working before seperating my prod(deploying initial version) and test env. FYI, my schema.prisma connection is that:
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}
2 Replies
Yetzederixx
Yetzederixx4mo ago
What I do is have a "fluid" .env file, and have my package.json file do something like this "migrate:dev": "cp .env.development .env && rest_of_commands"
Zurnadürüm
ZurnadürümOP4mo ago
well, thats not solution i am looking for, its workaround for problem
Want results from more Discord servers?
Add your server