ahcheng
ahcheng
PPrisma
Created by ahcheng on 6/17/2024 in #help-and-questions
Why doesn't the generated client use the .env file specified by dotenv?
package.json
{
"scripts": {
"migrate:dev": "dotenv -e .env.development -- npx prisma migrate dev"
}
}
{
"scripts": {
"migrate:dev": "dotenv -e .env.development -- npx prisma migrate dev"
}
}
.env
DATABASE_URL="mysql://xxx/t-prisma-test?schema=public"
DATABASE_URL="mysql://xxx/t-prisma-test?schema=public"
.env.development
DATABASE_URL="mysql://xxx/t-prisma-test-dev?schema=public"
DATABASE_URL="mysql://xxx/t-prisma-test-dev?schema=public"
After executing pnpm run migrate:dev, Prisma correctly loads the .env.development and creates tables in the t-prisma-test-dev database. However, when I query data using the client, I encounter the following error: 'Database t-prisma-test does not exist on the database server at localhost:3306. Why is the client operating on the t-prisma-test database specified in the .env file?'
3 replies