redwood icon indicating copy to clipboard operation
redwood copied to clipboard

Mitigate confusion and errors resulting from Prisma's Shadow DB 😈

Open thedavidprice opened this issue 3 years ago • 3 comments

I'm seeing more questions, issues, and errors resulting from confusion about Prisma Migrate's new Shadow DB. (Additionally, we have some similar confusion regarding Redwood's local Test DB requirements in case of switching off SQLite).

For context, see my answer to Thomas in the Forums: https://community.redwoodjs.com/t/creating-a-startup-support-crew/1805/38

Questions/Ideas

  • where and how can we improve documentation + instructions about this
  • is there any internal checks we can add to catch this in advance?
    • maybe Prisma could create a command to check if Shadow DB status == ok. We could run as part of flow and prompt with instructions if not ok
  • need to improve feedback loop with Prisma so they share in "feeling the pain"

Update

Help wanted --> see this comment re: next step auditing the current experience.

thedavidprice avatar Mar 24 '21 19:03 thedavidprice

@thedavidprice I hardly remembered that the shadow db is a thing. Do you think this is still a concern?

jtoar avatar Dec 13 '21 04:12 jtoar

@thedavidprice I'm going to close this one but feel free to re-open if you think we should address this for v1.

jtoar avatar Dec 17 '21 20:12 jtoar

@jtoar Re-opening this one — I'd like us to first audit the experience in the case where:

  • user sets only DATABASE_URL connection string to a cloud-hosted DB
  • then runs Prisma migrate commands

What happens? And is the resulting error clear about needing a second DB and how to set it up?

If the experience is adequate, then I'd say let's close it out.

thedavidprice avatar Dec 22 '21 22:12 thedavidprice

We get the following error :

Error: P3014

Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases. Read more about the shadow database (and workarounds) at https://pris.ly/d/migrate-shadow

Original error: 
db error: ERROR: permission denied to create database
   0: migration_core::state::DevDiagnostic
             at migration-engine/core/src/state.rs:250

The Prisma doc give a workaround by creating a dedicate shadow database from a cloud-hosted DB,

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

@thedavidprice I think the experience is adequate, we can maybe still add it to our doc as a head-up somewhere in this part : https://redwoodjs.com/docs/deploy/introduction#3-prisma-and-database

simoncrypta avatar Oct 27 '22 16:10 simoncrypta

Latest example of this is https://github.com/redwoodjs/redwood/issues/5767.

jtoar avatar Jan 29 '23 02:01 jtoar