Hard time with migrating prisma
youssef-el-atmani
FREEOP

7 months ago

4e6cbd4f-4d07-491a-9c53-1301d52e4923

Hi everyone,
If anyone here use the combination of: Railway, NestJs & Supabase
I have a hard time configuring the Supabase,
The Supabase is connected successfully to NestJs in Railway using ENV var of DATABASE_URL.

➡️ But I don't know how to migrate prisma,

I did run npx prisma migrate deploy locally but it didn't work

I checked the Supabase and I found that it did create a table that reflecting the initial migration, but there was two migrations missing, at the end I have deleted the table (I don't know actually how I did end creating that table, because I was fighting with that all the day, searching on my own and using AI, but no result)

Solved$10 Bounty

19 Replies

7 months ago

Have you tried using the Railway CLI's SSH capabilities to run the command?


7 months ago

Or alternatively, a Supabase Template


youssef-el-atmani
FREEOP

7 months ago

No I don't, since I have no idea about any of the deployment, this is my first deployed project ever

I'll look for those, thanks Adam a lot


youssef-el-atmani
FREEOP

7 months ago

Would you tell me please how would I use Railway CLI


youssef-el-atmani
FREEOP

7 months ago

to migrate the prisma


7 months ago

Is the install guide at the top of the page not enough?


7 months ago

There are step by step instructions for both installation and using the SSH capabilities in the docs


youssef-el-atmani
FREEOP

7 months ago

Okay thanks


youssef-el-atmani
FREEOP

7 months ago

I did the following:

  • installed the Railway CLI

  • Connected the shell to my Railway account
    and then I did run npx prisma migrate deploy,
    It did show:

Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "aws-0-ap-south-1.pooler.supabase.com:6543"

The shell like freezed, it didn't terminate, it just stayed there

I got a command from ChatGpt to check my DB connection is working: npx prisma db pull:
And also it did freeze on:

Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "aws-0-ap-south-1.pooler.supabase.com:6543"

- Introspecting based on datasource defined in prisma/schema.prisma

They took too long so that I terminate them manually


youssef-el-atmani
FREEOP

7 months ago

One thing to note, I am now using only the Trial Plan


7 months ago

Sounds like your command went through, why did you terminate it?


youssef-el-atmani
FREEOP

7 months ago

It did took too long


youssef-el-atmani
FREEOP

7 months ago

I will try a solution provided by Gemini, it suggest to use
npx prisma migrate deploy && npm start:prod
at Custom Start Command,
I did use that before, but it didn't work,

What Gemini, suggest is that

the Supabase connection pooler URL (the one that uses port 6543) is optimized for running queries from your application but is not compatible with running migrations. Migrations require a direct, non-pooled connection to the database to alter the schema.
I'll try to apply that and see if it gonna workout


youssef-el-atmani
FREEOP

7 months ago

I didn't read carefully:
Look what already Supabase is saying:

# Direct connection to the database. Used for migrations
DIRECT_URL="postgresql://postgres.arphbeijateuxclzjosv:[YOUR-PASSWORD]@aws-0-ap-south-1.pooler.supabase.com:5432/postgres"

It is clear that the DIRECT_URL is used for MIGRATIONS

I'll test it, and I hope that it will work


youssef-el-atmani
FREEOP

7 months ago


youssef-el-atmani
FREEOP

7 months ago

Thanks Adam
I did fix finally, I was frustrated all the day,

The problem is that I only added Transaction pooler,
When I got faced with the two existed links, I thoughts I had to choose between them, so that I did choose Transaction pooler, but the other one is the one used for migrations,

I got other Errors, but what matter now is that the DB Table did created successfully


7 months ago

great! glad to hear it. Am I good to mark this thread as solved?


youssef-el-atmani
FREEOP

7 months ago

Yes, it is solved, thanks


7 months ago

!s


Status changed to Solved adam 7 months ago


Loading...