Help with configuring prismaDB with supabase

Hello, I am trying to configure my projects prisma database with supabase, however I am struggling to get it to work. Whenever I run ‘yarn rw prisma migrate dev’, the migration seems to be running but never finishes. I do not get any errors in the process. I tried some fixes I found on the web but nothing worked. Here is my terminal:

Here are my .env and prisma.schema files:

datasource db {
  provider          = "postgresql"
  url               = env("DATABASE_URL")
  directUrl         = env("DIRECT_URL")
  schemas           = ["public", "auth"]
  shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}

generator client {
  provider        = "prisma-client-js"
  binaryTargets   = ["native", "rhel-openssl-3.0.x"]
  previewFeatures = ["multiSchema"]
}
# Transaction mode connection string used for migrations
DIRECT_URL="postgres://postgres.edrv..."

# Session mode connection string — used by Prisma Client
DATABASE_URL="postgres://postgres.edrv..."
# Shadow

# Transaction mode connection string used for migrations
SHADOW_DIRECT_URL="postgres://postgres.edrv..."

# Session mode connection string — used by Prisma Client
SHADOW_DATABASE_URL="postgres://postgres.edrv..."

The shadow url etc are because I tried the fix presented here (but to no avail) Yarn RW Prisma migrate Dev Breaks for Database_URL from Supabase · Issue #5767 · redwoodjs/redwood · GitHub

Thanks.

Hey @EReeeN1208, I couldn’t reproduce this with a simple example. Double checking that you’re close to your database? I.e., from the host, it looks like your database is in the EU. I’ve experienced significant slowness when running primsa migrations when my database isn’t close to me (I was in the UK and the database was on the west coast of the US).

The simple example I set up didn’t have quite the same prisma config, specifically multiSchema, so I could try adding that for sure. But did it work before and isn’t working now? Or is this the first time around you’re trying it out and it’s not working at all? Thanks!

Hi @EReeeN1208 i see you are adding in the auth schema. Last I looked there weee some issues with that because prisma diddnr supper some of the constraints and certain types.

I’ll try to find the Prisma issue.

That said, I really advise against including the auth schema. The intent of Supabase putting auth and user info there is so it’s not easily accessible.

If you need user info there is a technique to create a Prpfile table in public that gets updated in a trigger.

This way you never risk sharing secret info like tokens and password hashes etc.

See: Managing User Data | Supabase Docs
Also see Issues · prisma/prisma · GitHub

Hello. I tried removing “auth” from schemas. The same error persists when I try to migrate (The migration gets stuck). How long should it normally take?

Thanks.

Yes the database should be fairly close. (Turkey → Central EU). I removed the the lines about multiSchema but the same error still persists. Interestingly, it does seem to be making requests to supabase.

Could the migration just be taking some time? (There is already a bit of data in the database)