Migrate: Unable to run prisma migrate with dotenv-cli

Created on 27 Aug 2020  路  2Comments  路  Source: prisma/migrate

Problem
Unable to run prisma migrate with dotenv-cli

Reproduction
$ dotenv -e .env prisma migrate save --experimental
Error: Please provide the --experimental flag to use this command.

Link to Slack thread

This is my second Github issue. Apologise if it doesn't live up to standard.

kindocs tectypescript cli-migrate-save env

Most helpful comment

@janpio After looking it looks like it works as intended.

The problem here is that dotenv-cli doesn't pass flags like --experimental by default.

@mikkelsl To make it work change your command to:

    # I added two dashes before the prisma command
    dotenv -e .env -- prisma migrate save --experimental

This can be found in the README of dotenv-cli

Flags to the underlying command

If you want to pass flags to the inner command use -- after all the flags to dotenv-cli.

I created a PR to make it clearer in the docs https://github.com/prisma/docs/pull/834

All 2 comments

This issue is perfect.

And unfortunately I can also confirm the problem:

C:\Users\Jan\Documents\throwaway\studioTestin2>npx prisma migrate save --experimental
Error: P1012

Get config 
error: Environment variable not found: DATABASE_URL.
  -->  schema.prisma:7
   | 
 6 |   provider = "mysql"
 7 |   url      = env("DATABASE_URL")
   | 

Validation Error Count: 1


C:\Users\Jan\Documents\throwaway\studioTestin2>npx dotenv -e .env npx prisma migrate save --experimental
Error: Please provide the --experimental flag to use this command.

(I moved my .env from next to the schema to the root of my project)

@janpio After looking it looks like it works as intended.

The problem here is that dotenv-cli doesn't pass flags like --experimental by default.

@mikkelsl To make it work change your command to:

    # I added two dashes before the prisma command
    dotenv -e .env -- prisma migrate save --experimental

This can be found in the README of dotenv-cli

Flags to the underlying command

If you want to pass flags to the inner command use -- after all the flags to dotenv-cli.

I created a PR to make it clearer in the docs https://github.com/prisma/docs/pull/834

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steebchen picture steebchen  路  3Comments

agryaznov picture agryaznov  路  3Comments

mariushab picture mariushab  路  3Comments

ff-anthony-soto picture ff-anthony-soto  路  3Comments

2013-11390 picture 2013-11390  路  3Comments