Migrate: Migrate migration contains ENV variables

Created on 13 Jan 2020  路  5Comments  路  Source: prisma/migrate

There is a strange content of the migration steps. Please confirm.

Steps to reproduce:

  1. Have the schema with ENV variables:
    image
  2. Change the model (keeping the datasources the same)
  3. Call npx prisma2 dev and check the migration steps:

image

There are two suspicious things:

  1. "enabled" declaration contains real env(XX) definition
  2. "url" declaration contains differs by the env(XX) definition, before there was marked "*" instead.

Is that right please ?

bu2-confirmed kinbug

All 5 comments

I can confirm this in the latest preview020.3. Since prisma2 dev has been removed, you can reproduce this by creating two migrations with prisma2 migrate.

Schema for reproduction:

datasource sqlite {
 provider = "sqlite"
 url = env("DATABASE_URL")
 enabled = env("DATABASE_DEV")
}

datasource db {
  provider = "postgresql" // other options are: "mysql" and "sqlite"
  url      = env("DATABASE_URL")
  enabled  = env("DATABASE_PROD")
}

generator client {
  provider = "prisma-client-js"
}

model User {
  id String @id @default(cuid())
  name String
  test String
}

Internal note: dropping from current sprint

When trying to create a DB with a similar config, the cryptic error I received offered no help in terms of what was going on:

Cannot read property 'enabled' of undefined

I suspect I'm not the only dev to have spent a fair bit of time trying to track down this issue. It seems like the database config isn't being properly loaded if there are multiple sets of env variables, which is likely quite common as many configs want to reference different sources for prod/dev. Should be relatively easy to track down and would likely save users a lot of time/frustration.

Would highly recommend it be prioritized as an easy win.

@ssalbdivad enabled has been removed from the schema for a while now.

This is still a problem, updated schema for reproduction:

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

generator client {
  provider = "prisma-client-js"
}

model User {
  id String @id @default(cuid())
  name String
  test String
}

I did some fiddling around with prisma 2.2.0, and the README diff now shows up like this:

Screenshot from 2020-07-08 10-33-21

This is a bit noisy but doesn't do anything, it's a CLI issue.

The steps.json now always have the url anonymized (***), consistently, and are idempotent, so I think the only problem now is the noise in the README diff.

Was this page helpful?
0 / 5 - 0 ratings