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
Provide better error message when migrate
is unable to find shadow database in Supabase
#10575
Comments
Solution for a tool like Supabase is to create another instance of PostgresSQL as shadow database. I'm closing this issue now. |
Great that you found a workaround. Optimally you should have gotten an error message telling you about the workaround though, and not this:
We should investigate why that error message is not triggering on Supabase. |
For any future Prisma + Supabase users Googling this, if, like me, you were trying to do fully-local development, literally following these steps from the original post:
You probably read the docs here on manually creating a shadow database here, but those docs heavily imply creating a cloud database. However, AFAIK, there's nothing preventing you from spinning up a local shadow Supabase DB for Prisma to use via, say, The following worked for me. Put this in a version: '3.8'
services:
# Prisma uses this database to detect schema drift and other dev checks
# See https://www.prisma.io/docs/concepts/components/prisma-migrate/shadow-database
supabase-shadow:
image: supabase/postgres:14.1.0
command: postgres -c config_file=/etc/postgresql/postgresql.conf
restart: unless-stopped
ports:
- 12345:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
# 👇 Change this volume mapping to something that makes sense for you
- ~/.docker/storage/data:/var/lib/postgresql/data
- ~/.docker/storage/init:/docker-entrypoint-initdb.d Then add the shadow DB URL to your DATABASE_URL="postgresql://postgres:postgres@localhost:10150/postgres"
SHADOW_DATABASE_URL="postgresql://postgres:postgres@localhost:12345/postgres" And finally update your datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
} With that, I'm able to run and generate migrations with Prisma, while running the typical Supabase local dev environment with Hope that helps! |
An alternative method to spinning up a shadow db locally by creating a Here are the steps (assuming you have initialized supabase and have a
Note: you don't have to init the supabase project inside of your |
This works for me. Not sure of the side effects, but it works.
|
migrate
is unable to find shadow database in Supabase
Bug description
I'm trying to generate some migrations using Prisma.
I'm using Supabase which is using Postgres under the hood.
Also, I tried to run the following command with the local emulator and with the "real project".
When I run
prisma db push
it's working, so the communication between prisma and supabase can be established. But when I try to runprisma migrate dev
I get the following errorHow to reproduce
supabase init
supabase start
prisma migrate dev
Expected behavior
Migrations are generated
Prisma information
It's not my real schema which is private, but I tested with this one and it's also failing 😬
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: