postgresqlprismasupabase

Prisma Supabase: Invalid format for user or db_name after initial migration


I recently moved from NeonDB to Supabase for postgres hosting, the setup has been a nightmare and I've been stuck for two days

For context, the supabase project is new. I tried resetting / deleting and making a new one.

After running these commands

npx prisma generate
npx prisma migrate dev --name init

I always get this error

Error: FATAL: Authentication error, reason: "Invalid format for user or db_name"
   0: schema_core::state::DevDiagnostic
             at schema-engine/core/src/state.rs:276

This is the error I get in the supabase logs

relation "_prisma_migrations" does not exist

And the query that caused this error

SELECT \"id\", \"checksum\", \"finished_at\", \"migration_name\", \"logs\", \"rolled_back_at\", \"started_at\", \"applied_steps_count\"

FROM \"_prisma_migrations\"

ORDER BY \"started_at\" ASC

I really think I tried every solution on the internet. I have no idea why this happens, never had a single issue with NeonDB. Any ideas?

schema.prisma

generator client {
    provider = "prisma-client-js"
}

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

My .env

# Connect to Supabase via connection pooling with Supavisor.
DATABASE_URL="postgresql://postgres.jdjgwzijrvzkmobplscq:[ALPHANUMERIC_PASS]@aws-0-eu-west-3.pooler.supabase.com:6543/postgres?pgbouncer=true"

# Direct connection to the database. Used for migrations.
DIRECT_URL="postgresql://postgres.jdjgwzijrvzkmobplscq:[ALPHANUMERIC_PASS]@aws-0-eu-west-3.pooler.supabase.com:5432/postgres"

Solution

  • I had the same issue today. I just switched Supabase project to another server location (had the issue when using french server location aws-0-eu-west-3.pooler.supabase.com and fixed it by using german server location aws-0-eu-central-1.pooler.supabase.com) and it worked perfectly.

    Have fun! 👋