Prisma db push or pull stuck?

Fix for Prisma connection stuck.

When working with Prisma and Supabase DB, I got an issue with the Prisma CLI getting stuck during prisma db push and prisma db pull. I eventually for to know that the issue often arises when using a Supabase …


This content originally appeared on DEV Community and was authored by Abdullah Bashir

Fix for Prisma connection stuck.

When working with Prisma and Supabase DB, I got an issue with the Prisma CLI getting stuck during prisma db push and prisma db pull. I eventually for to know that the issue often arises when using a Supabase connection string with the pooled connection (port 6543).

For example, running npx prisma db push took 9 minutes here and still failed:

Slow execution

The Fix

To resolve this, I needed to switch to a direct connection string using port 5432 instead. I tried changing it on the Supabase dashboard and then saw this:

Supabase Dashboard

What you need to change:

# Old Pooled Connection
DATABASE_URL="postgresql://...@db.supabase.co:6543/db"
DIRECT_URL="postgresql://...@db.supabase.co:6543/db"

# New Direct Connection
DATABASE_URL="postgresql://...@db.supabase.co:6543/db"
DIRECT_URL="postgresql://...@db.supabase.co:5432/db"
// What your Prisma Datasource initialiser should look like
generator client {
  provider = "prisma-client-js"
}

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

Now, let's see how it runs:

Fast Execution

Happy Hacking!

PS: For more details, check out the GitHub discussion.


This content originally appeared on DEV Community and was authored by Abdullah Bashir


Print Share Comment Cite Upload Translate Updates
APA

Abdullah Bashir | Sciencx (2024-08-18T14:19:56+00:00) Prisma db push or pull stuck?. Retrieved from https://www.scien.cx/2024/08/18/prisma-db-push-or-pull-stuck/

MLA
" » Prisma db push or pull stuck?." Abdullah Bashir | Sciencx - Sunday August 18, 2024, https://www.scien.cx/2024/08/18/prisma-db-push-or-pull-stuck/
HARVARD
Abdullah Bashir | Sciencx Sunday August 18, 2024 » Prisma db push or pull stuck?., viewed ,<https://www.scien.cx/2024/08/18/prisma-db-push-or-pull-stuck/>
VANCOUVER
Abdullah Bashir | Sciencx - » Prisma db push or pull stuck?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/18/prisma-db-push-or-pull-stuck/
CHICAGO
" » Prisma db push or pull stuck?." Abdullah Bashir | Sciencx - Accessed . https://www.scien.cx/2024/08/18/prisma-db-push-or-pull-stuck/
IEEE
" » Prisma db push or pull stuck?." Abdullah Bashir | Sciencx [Online]. Available: https://www.scien.cx/2024/08/18/prisma-db-push-or-pull-stuck/. [Accessed: ]
rf:citation
» Prisma db push or pull stuck? | Abdullah Bashir | Sciencx | https://www.scien.cx/2024/08/18/prisma-db-push-or-pull-stuck/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.