Hey everyone, I have an issue with using Primsa ORM + Doppler. To initialize my Postgres db via Prisma, I have to connect to the db via a schema.prisma file. You can either provide a raw URL string or an env variable with the env() command. Here’s how my datasource looks:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
This works if DATABASE_URL is defined in a .env file in my local repo. However, I’m using Doppler secret management to insert env variables in at runtime. If I remove the .env file then Prisma throws an Environment variable not found
error because it can’t fetch the env variable from Doppler. All my other Doppler env variables work in my other files by calling process.env.ENV_VAR_NAME
, so I’m not sure how to load doppler env variables in before schema.prisma runs.
Here’s my current package.json script, which runs doppler before prisma: doppler run -- prisma generate --schema=./infrastructure/database/schema.prisma && prisma migrate dev --name=updateModel --schema=./infrastructure/database/schema.prisma