Help with using Prisma Data Proxy with Prisma CLI commands (migrate, etc)

The docs on this are fairly sparse, and I plan to update them based on whether I/we can figure this out. I couldn’t find anything on configuring the deployment scripts etc, but if I missed something, please let me know.

Onto the issue -

The setup for Prisma Data Proxy is to change your DATABASE_URL environment variable from your postgress:// or mysql:// etc. to the generated prisma:// URL.

If you do this, and try to deploy, you’ll get the following message:

The solution is to swap that environment variable for that command, see this small Prisma doc

But I can’t find the block of code that’s running the Prisma migrate command - I can only see that it’s running the following: yarn prisma migrate deploy --schema /vercel/path0/api/db/schema.prisma. I haven’t looked at the source code yet, so it’s possible that this isn’t yet configurable - please let me know if this is the case and I can work on a patch. Basically, in order to use this feature, that command needs to be modified in the way described by the Prisma docs linked to previously.

Is there a recommended way to do this?

Thanks!

Has anyone done anything like this? :slight_smile: @rob any insights?

I haven’t done anything like that, sorry! Running yarn rw prisma we just forward that to the real yarn prisma command behind the scenes, however we do inject some extra flags for you automatically. That all happens in here: redwood/prismaHandler.js at main · redwoodjs/redwood · GitHub

Does that help?

1 Like

Hi again! :wave:

This looks like a similar problem to when you need to migrate a database that has connection pooling.

I think if you follow the prisma doc, it should solve your issue. What they’re saying is essentially, you use the prisma:// connection string when you build your app, but use the direct postgres:// when you are running a migrate. It is essentially the same process as I described here for supabase [Guide] Migrations & Connection Pool URLs (Supabase)

Hope this helps!

1 Like

This looks perfect, thanks @danny! I’ll give it a try and report back.

I had no clue we could modify the CI scripts in that way! Is that anywhere in the docs?

It didn’t work - replied back on that thread.