-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Problem
By default when we initialize a Prisma project, we write an environment file to prisma/.env. This layout works for us but is unusual and incompatible with projects (e.g. next.js, blitz, redwood, create-react-app projects) that assume .env is in the project root.
If you try moving prisma/.env into the project root, you'd also need to move prisma/schema.prisma to the project root. This approach is documented, but subtle.
For context, there are two components that rely on .env:
- The CLI when introspecting and migrating.
- The generated database client when connecting to the database.
Suggested solution
I'd suggest we change our defaults from prisma/.env and prisma/schema.prisma to .env and schema.prisma. If someone already has an .env file, we append our default environment variable (DATABASE_URL) to the bottom of their existing .env file.
Alternatives
Do nothing
Don't change anything. Add a bit of documentation saying how you can make Prisma work with your existing .env file.
Initialize to .env and prisma/schema.prisma
prisma init could also write .env and prisma/schema.prisma instead of writing both files to the project root. I don't really see a reason to create a subdirectory with only 1 file (by default), but I also don't have strong opinions on this.
Related
- We should decide on Allow .env in the project root with the Prisma Schema somewhere else #3720 before deciding on this issue.