Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Prisma generate independent of environment #593

Closed
divyenduz opened this issue Sep 23, 2019 · 6 comments
Closed

Make Prisma generate independent of environment #593

divyenduz opened this issue Sep 23, 2019 · 6 comments
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Milestone

Comments

@divyenduz
Copy link
Contributor

divyenduz commented Sep 23, 2019

prisma generate fails when a particular environment variable is not available. The reason(s) for this are:

datasource ds {
  provider = env("DB_PROVIDER")
  url = env("DB_URL")
}

If DB_PROVIDER is used, then the generate CLI needs to resolve it to proceed as it needs to know the data source. A potential solution is to dis-allow environment variables in provider. This issue: prisma/prisma-client-js#184 also ties into this discussion.

Decision: Disallow env vars in provider

If DB_URL is used, then for SQLite, we need to be able to resolve the relative path to the SQLite file at generate time, to be able to use it at runtime. A potential solution is to limit SQLite to absolute paths but that is not the best DX.

Decision: Do not resolve SQLite path when generation

Had a quick chat with @schickling and the result is above marked decisions.


Another alternative is to fail only on the required env vars (like provider) but let others pass through. That would require the datamodel parser to bake the field information in the parse tree and that can be used to fail conditionally.


This information is from top of my head and might be outdated, I will sync with @timsuchanek on this.

@divyenduz divyenduz added the kind/improvement An improvement to existing feature and code. label Sep 23, 2019
@schickling schickling added bug/2-confirmed Bug has been reproduced and confirmed. process/candidate and removed kind/improvement An improvement to existing feature and code. labels Oct 2, 2019
@janpio janpio added the kind/bug A reported bug. label Oct 11, 2019
@janpio janpio added this to the Preview 15 milestone Oct 11, 2019
@divyenduz
Copy link
Contributor Author

divyenduz commented Oct 11, 2019

Internal note: This happens without schema parser, i.e. no VSCode support

VSCode support tracked here prisma/language-tools#17

@matthewmueller
Copy link
Contributor

Matt: Update spec to include "Disallow env vars in provider"

@mavilein
Copy link
Contributor

Env vars are now disallowed in the provider argument of datasources (PR). This will be available in alpha shortly.

@marcjulian
Copy link
Contributor

Updating from prisma 2.0.0-beta.2 to 2.0.0-beta.3 I am now receiving the following error

npx prisma generate
Error: Schema parsing
error: Error validating source `db`: You must provide a nonempty URL for the datasource `db`. The environment variable `POSTGRESQL_URL` resolved to an empty string.
  -->  schema.prisma:3
   | 
 2 |   provider = "postgresql"
 3 |   url      = env("POSTGRESQL_URL")
   |

I am setting an empty string for POSTGRESQL_URL for npm install. This error occurs on GitHub actions and the error is available here

@pantharshit00
Copy link
Contributor

@marcjulian Can you please open a new issue about this?

@marcjulian
Copy link
Contributor

Added the issue 2321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

8 participants