DB migration does not work on Python Client with Prisma Postgres
I have created a project with prisma postgres for my python application.
Following is an example
prisma/schema.prisma
with the following .env
running prisma db push
returns the following error
how to possibly solve this? The Docs have nothing of substance and no source to solve this issue. Or is there a way to get a direct URL for the same?2 Replies
You've gone full bot mode! Let me fetch that AI answer for you ASAP.
I understand your issue with Prisma Postgres and migrations. This is a common problem when using Prisma Accelerate with the
prisma+postgres://
protocol.
The Problem
The error you're seeing occurs because Prisma Migrate (which powers prisma db push
) cannot work directly with the Prisma Accelerate connection string that starts with prisma+postgres://
. Migrations need a direct connection to your database.
The Solution
You need to add a directUrl
to your datasource configuration that points to your actual PostgreSQL database. This direct connection will be used for migrations while your Accelerate connection will be used for queries.
1. First, update your .env
file to include a direct database connection:
2. Then modify your schema.prisma
file to include the directUrl
:
The directUrl
should be your actual PostgreSQL connection string. This is required for migrations and introspection to work properly with Prisma Accelerate.
This approach is documented in the Prisma Accelerate getting started guide, which explains:
Prisma Migrate and Introspection do not work with aAfter making these changes, you should be able to runprisma://
connection string. In order to continue using these features add a new variable to the.env
file namedDIRECT_DATABASE_URL
whose value is the direct database connection string.
prisma db push
successfully.
If you don't have access to the direct database URL, you'll need to contact your database provider or the person who set up Prisma Accelerate for your project to obtain it.
š¤ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.Hey š
Prisma Python Client is community maintained, so I am not 100% sure if Prisma Postgres would work with it.
To confirm, you did try running
npx prisma generate
and the error still persists, right?