Skip to content

Datasource url should be optionally dynamic (preserve env()) #287

Closed

Description

@chrisui

Currently prisma generate with a datasource of env() appears to write in the value at build time. This breaks stateless builds (which are always runtime configurable and doesn't require prevent building between environments).

It would be better if env("NAME") could instead be built into process.env["NAME"].

Ie.

datasource pg {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Should generate...

class Photon {
  internalDatasources = [
    {
       "name": "pg",
       "connectorType": "postgresql",
       "url": process.env["DATABASE_URL"],
       "config": {}
    }
  ]
}

Activity

  1. Errorname commented on Jul 30, 2019

    @Errorname
    Contributor

    Hello! There is a discussion about this here: #227, you can explain your use case there to push this subject forward

  2. timsuchanek commented on Aug 5, 2019

    @timsuchanek
    Contributor

    Fixed in latest version.

  3. kldzj commented on Jun 16, 2020

    @kldzj

    Hi @timsuchanek, it seems like the generated client still (or possibly again?) contains the database connection string. Is there something other than creating a post-postinstall script that replaces the connection string with a call to read from process.env that we can do on our side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions