question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow environment expressions inside the Prisma Schema

See original GitHub issue

Problem

Today we support variable expressions within the .env file:

USERNAME="postgres"
DATABASE_URL="postgres://${USERNAME}@localhost:5432/repro"

But we don’t currently support environment expression inside the Prisma Schema. This prevents us from separating configuration from the environment.

This lack of separation means you need to either hardcode values in the Prisma Schema or move more configuration into the environment.

Presently, environment expressions would mostly be a quality of life improvement and taking better advantage of our Prisma Schema as a configuration language.

In the future, I sense this will become more important as we need more configuration (e.g. prisma migrate configuration, prisma introspect configuration.)

Configuration vs. Environment

  • Configuration are settings in your application that don’t change. You want this in source control.
  • Environment are settings or secrets that change across the environment. You don’t want your secrets in source control.

You can find this separation in practice in popular frameworks:

Suggested solution

Extend our Prisma Schema syntax to support template expressions.

datasource pg {
  provider = "postgres"
  url = "${env("DATABASE_URL")}?sslidentity=/tmp/client-identity&sslcert=${env("SERVER_CA")}"
}

Alternatives

Extend our schema in some other way.

Related

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:13
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
BjoernRavecommented, Oct 12, 2020

@janpio this issue was created in response to: https://github.com/prisma/prisma/issues/1673#issuecomment-682438993

It would be useful to be able to connect to a DB via SSL in a serverless context.

Currently you need to jump through a lot of hoops to get SSL working on vercel.

This, together with the ability to pass sslcert etc. as a env var and not as a file, would make this much easier

0reactions
janpiocommented, Mar 28, 2022

I think the example from @matthewmueller above is just poorly chosen, this issue is not about being able to provide a certificate as a a string at all. Please open a new feature requests for this (or look for an existing one). Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment variables - Prisma
An environment variable is a key value pair of string data that is stored on your machine's local environment. Refer to our Environment...
Read more >
Prisma schema (Reference)
You can use environment variables to provide configuration options when a CLI command is invoked, or a Prisma Client query is run. ......
Read more >
Managing .env files and setting variables - Prisma
Learn how to manage .env files and set environment variables. ... the DATABASE_URL environment variable which is often used for the database connection...
Read more >
Environment variables reference - Prisma
DEBUG. DEBUG is used to enable debugging output in the Prisma Client. Example setting Prisma Client level debugging output: · NO_COLOR. NO_COLOR if...
Read more >
Prisma schema API (Reference)
Sets whether referential integrity is enforced by foreign keys in the database or emulated in the Prisma Client. In preview in versions 3.1.1...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found