#Setting up multiple Postgres environments properly

4 messages · Page 1 of 1 (latest)

supple hornetBOT
#

You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into #ask-ai for a quick spin!

rose patio
#

I assume the issue is resolved?
Please let me know in case you still need any help

azure falcon
#

Hey @rose patio, I had 2 question threads open so I wanted to be consious of everyones time and open one at a time, I tried to delete this one but it only deleted my message. If you have the time, I'd really appreciate your feedback. Here was my original message:

I have only used Prisma for hobby projects so I have never worked with scalability in mind but I am trying to scale one of my projects properly and am looking for some guidance on "best practices" of setting up a db per environment (along with a shadow db).

When initially setting up my db for this project, I made a free db through Vercel Postgres (which is now through neon) and I have a shadow db (though supabase) that I believe I needed to set up to run a migration. Since I am doing this change, I figured it made sense to also move all these dbs in a single source, so I am looking to set up these environments in my Prisma Postgres dashboard. I have made a project and set up a develpment and production environment within the project. I am assuming I should make a db within each of these environments, and then does it also make sense to set up a "shadow" environment to host the db to help run migrations?

And further, what fields are required in my datasource object? I believe when I set my project up with Vercel I was instructed to use this structure:

datasource db {
  provider          = "postgresql"
  url               = env("POSTGRES_PRISMA_URL")
  directUrl         = env("POSTGRES_URL_NON_POOLING")
  shadowDatabaseUrl = env("POSTGRES_SHADOW_URL")
}

But when looking at the Prisma docs, this is all I see:

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

I apologize for the vagueness on this question but I hope I provided enough info for some feedback on how to proceed. Thank you in advance!

rose patio
#

@azure falcon Thank you so much for explaining the question in detail.
It is not mandatory to pass a shadowDatabaseUrl. Shadow database is created automatically if database user has appropriate access.

In your use case, as you are using a Prisma Postgres database, you would not need to create a shadow database, as it will be created automatically. So, no need to pass shadowDatabaseUrl parameter.

This docs page will be helpful to know more about shadow database:
https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database