Provide better error message when migrate is unable to find shadow database in Supabase
See original GitHub issueBug 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 run prisma migrate dev
I get the following error
Error: db error: ERROR: no such database: prisma_migrate_shadow_db_b2ce3e4e-c5ef-41f6-830f-2203a082f1db
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:367
1: migration_core::api::DevDiagnostic
at migration-engine/core/src/api.rs:108
How to reproduce
- Download Supabase CLI
supabase init
supabase start
- Init prisma
- Run
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 😬
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(dbgenerated("extensions.uuid_generate_v4()")) @db.Uuid
name String @unique @db.VarChar(255)
@@map("users")
}
Environment & setup
- OS: MacOS
- Database: PostgreSQL with Supabase
- Node.js version: v14.17.4
Prisma Version
prisma : 3.6.0
@prisma/client : 3.6.0
Current platform : darwin
Query Engine (Node-API) : libquery-engine dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : dc520b92b1ebb2d28dc3161f9f82e875bd35d727
Studio : 0.440.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Prisma migration fail with supabase - Stack Overflow
I'm using Supabase which is using Postgres under the hood. Also, I tried to run the following command with the local emulator and...
Read more >Supabase CLI v1 and Management API Beta
The Supabase CLI is capable of managing database migrations and generating TypeScript types. Follow these install instructions to get ...
Read more >About the shadow database - Prisma
If Prisma Migrate does not detect schema drift, it moves on to generating new migrations. ... Error: A migration failed when applied to...
Read more >How to Build a Fullstack App with Next.js, Prisma, and ... - Vercel
Create the tables in your database based on your Prisma schema. You should see the following output: Environment variables loaded from /Users/nikolasburk/ ...
Read more >I have a project I m working on and Supabase is the DB and I | Orm ...
I updated my ENV vars with the shadow DB and deployed. All deployed without errors except I'm still getting the 500-Failed to load...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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,
docker-compose.yml
.The following worked for me.
Put this in a
docker-compose.yml
file and rundocker-compose up
:Then add the shadow DB URL to your
.env
file:And finally update your
schema.prisma
to pointshadowDatabaseUrl
to your local shadow DB:With that, I’m able to run and generate migrations with Prisma, while running the typical Supabase local dev environment with
supabase start
.Hope that helps!
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.