2 months ago
Loaded Prisma config from prisma.config.ts.
Prisma schema loaded from prisma/schema.
Generated Prisma Client (v7.2.0) to ./node_modules/.pnpm/@prisma+client@7.2.0_prisma@7.2.0_@types+react@18.3.18_react-dom@19.2.3_react@19.2.3__react@1_mjdrmvbq545cdg4sflwm6veu7u/node_modules/@prisma/client in 269ms
Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)
Tip: Need your database queries to be 1000x faster? Accelerate offers you that and more: https://pris.ly/tip-2-accelerate
> kun-nestjs@0.0.1 migration:run:prod /app
> prisma migrate deploy
Loaded Prisma config from prisma.config.ts.
Prisma schema loaded from prisma/schema.
Datasource "db": PostgreSQL database "railway", schema "public" at "postgres.railway.internal:5432"
6 Replies
2 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 2 months ago
2 months ago
the issue is that postgres.railway.internal isnt available during build phase
you need to run your migrations in the start command instead of build command so they run when private networking is available
change your start command to:
npx prisma migrate deploy && npm start
or if you have a different start script:
npx prisma migrate deploy && node dist/main.js
this runs migrations at deploy time when the private network is accessible. dont put prisma migrate in your build command anymore, you can also run this as part of pre-deploy command feature
2 months ago
hope this help you
ilyassbreth
the issue is that postgres.railway.internal isnt available during build phaseyou need to run your migrations in the start command instead of build command so they run when private networking is availablechange your start command to:npx prisma migrate deploy && npm startor if you have a different start script:npx prisma migrate deploy && node dist/main.jsthis runs migrations at deploy time when the private network is accessible. dont put prisma migrate in your build command anymore, you can also run this as part of pre-deploy command feature
2 months ago
This is likely the cause, but I would highly advise not running this as part of the start command (especially if you have replicas), and instead running it as a Pre-Deploy Command. It is designed specifically for this kind of operation.
2 months ago
yes ofc , best solution is to use railway's pre-deploy command feature. it runs between build and deploy when private networking is available, and its designed specifically for migrations.
in your railway service settings:
- find "pre-deploy command" section
- add: npx prisma migrate deploy
this is better than putting it in start command especially if you scale to multiple replicas later since pre-deploy runs once before deployment while start command would run on every replica
2 months ago
The issue might actually be deeper than just a missing env var or a database delay. It is often related to how Prisma binaries are packaged during the build process.
I have a Node.js + Prisma + Redis template that solves this specific issue. It’s pre-configured to handle the packaging correctly and runs migrations safely in the pre-deploy stage. You can check it out here: https://railway.com/deploy/nodejs-multimodal-rag-starter?referralCode=2psx_t&utm_medium=integration&utm_source=template&utm_campaign=generic
2 months ago
hy @eee , did solution end up fixing everything on your end?