Schema.prisma is not reading the environment variables injected by elastic beanstalk #15561
-
Bug descriptionHello, when I set the env variable DATABASE_URL in elastic beanstalk, then SSH into the deployment and run 'npx prisma migrate deploy' I get the error: `[ec2-user@ip-172-31-26-198 current]$ npx prisma migrate deploy Validation Error Count: 1 Prisma CLI Version : 4.3.1` if I hardcode in the url, the migration will work, but i'd like for it to be dynamic as we'll have multiple environments. It appears that prisma searches the app for a .env file to draw the values from when this is run How to reproduceExpected behaviorThe schema should find the DATABASE_URL being added by elastic beanstalk and the database migrations should run. Prisma informationgenerator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
} Environment & setup
Prisma Version
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @NathanFrank285, thanks for opening this issue.
Prisma resorts to the |
Beta Was this translation helpful? Give feedback.
-
There is another solution, which is to set dotenv import dotenv from "dotenv";
dotenv.config(); |
Beta Was this translation helpful? Give feedback.
Hi @NathanFrank285, thanks for opening this issue.
Prisma resorts to the
.env
file only if it cannot find the variables it needs in the environment.As a sanity check, can you please print your database url by running
echo $DATABASE_URL
before attempting to runnpx prisma migrate deploy
in your[ec2-user@ip-172-31-26-198 current]
SSH session? I think the issue is that the environment variable set in Elastic Beanstalk is not available in your SSH session, as it is not persisted to your profile file.