Prisma can't reach database server (during build)

AnonymousTRIAL

a year ago

Hello, I would like when deploying my application to synchronize the migrations with the database that I also have on railway. So I added this command during the build.

"build": "prisma migrate deploy && nest build"

but unfortunately I have this error. I also had it when I put it on the script to start the application after building, and it only worked when I restarted the server.

0 Replies

AnonymousTRIAL

a year ago

2b4c4fbf-3975-4801-970c-47c4c97d9fe0


a year ago

the private network is not available during build yet


AnonymousTRIAL

a year ago

So why I had the error also when commanding to start the application?


AnonymousTRIAL

a year ago

for DATABASE_URL variable i use the ref to ${{Postgres.DATABASE_PRIVATE_URL}}


AnonymousTRIAL

a year ago

so i have to use ${{Postgres.DATABASE_URL}}?


a year ago

because you would need to have a 3 second delay before attempting to connect to a private service


a year ago

yes you would have to use the public url if you want to run migrations during build, or continue using the private network and run the migrations at runtime before starting your app


AnonymousTRIAL

a year ago

what configuration do you recommend?


a year ago

before you change anything, try enabling their new builder, I forget if it is a part of the private network, but I know it would be the end goal so maybe it's already implemented


AnonymousTRIAL

a year ago

ok i try


AnonymousTRIAL

a year ago

i need a nixpacks.toml ?


a year ago

not necessarily, why do you ask?


AnonymousTRIAL

a year ago

it does not take the configuration on railway directly


AnonymousTRIAL

a year ago

so he sends this back to me Error: No start command could be found


a year ago

I'm not sure what you mean, you need to set that variable as a service variable, have you?


a year ago

How were you previously setting your start command?


AnonymousTRIAL

a year ago

it does not use the custom start command that I put in the parameters of my service


AnonymousTRIAL

a year ago

I did not change this command when I changed the builder version


AnonymousTRIAL

a year ago

I would therefore like to create a nixpacks configuration file, but the problem is that I don't know what to put in nixPckgs apart from nodejs


AnonymousTRIAL

a year ago

because when I don't use the nixpacks file, by default it uses nodejs, npm and openssl


a year ago

so you already have a nixpacks.toml file?


AnonymousTRIAL

a year ago

so you already have a nixpacks.toml file?


AnonymousTRIAL

a year ago

I tried to put it on to see what we could do, but I took it off


a year ago

okay, you're all over the place and I don't know what the current issue is.

so let's start off without a nixpacks.toml file, what kind of app do you have?


AnonymousTRIAL

a year ago

i have a nestjs app


AnonymousTRIAL

a year ago

my question is but is it recommended to do the migration during the build or start?


a year ago

start because then you can use the private network. but I have asked you to try running the migration during build with the v2 builder


AnonymousTRIAL

a year ago

yes but i need nixpacks.toml to run the v2 builder


a year ago

why is that


AnonymousTRIAL

a year ago

I'm going to put the whole context back


AnonymousTRIAL

a year ago

I had the bug concerning prisma which could not connect to my database during the build via the internal url, because during the build there is no access to the internal network. You therefore suggested that I use the builder v2 which could potentially solve this problem. So I activated the builder v2 via the variables. But I noticed that it does not find a start command even though I put a custom start command on the settings of my backend service (on railway directly). So I wanted to create a nixpacks.toml configuration file to define the build, start, etc. commands… But the problem is that I noticed that I didn't know what to put in nixPcks in the setup phase. Because without a nixpacks.toml file, it has nodejs20, npm9 and openssl as default. And in mine I just put nodejs, and I didn't know if I should put other things.
So I'm just wondering if it's better to migrate my database during start or during build. To me this makes more sense during the build. But in this case, I would like someone to explain the nixpacks.toml configuration file to me.


AnonymousTRIAL

a year ago

@Brody If you have any questions do not hesitate. sorry I wasn't on my pc before


a year ago

I'm sorry but I don't currently have the time to read all that, instead I would greatly appreciate if you could directly answer my previous question


AnonymousTRIAL

a year ago

I noticed that it does not find a start command even though I put a custom start command on the settings of my backend service (on railway directly).


AnonymousTRIAL

a year ago

1246171762173939700


AnonymousTRIAL

a year ago

but the builder v2 return this


AnonymousTRIAL

a year ago

1246171906634285000


a year ago

thank you for this clear and concise answer, try adding a start script to your package.json instead


AnonymousTRIAL

a year ago

I see that it deletes lots of files, why?

60 store paths deleted, 512.58 MiB freed


AnonymousTRIAL

a year ago

this v2 is used to take up less space for snapshots?


a year ago

the new builder is much more verbose, I don't think you need to pay much mind to what it prints


AnonymousTRIAL

a year ago

it takes much longer


AnonymousTRIAL

a year ago

1246175492780851200


AnonymousTRIAL

a year ago

it fail


AnonymousTRIAL

a year ago

1246176841820278800


AnonymousTRIAL

a year ago

after 10min


a year ago

with what error


AnonymousTRIAL

a year ago

nothing


AnonymousTRIAL

a year ago

it's the last logs


AnonymousTRIAL

a year ago

i come back to build v1


AnonymousTRIAL

a year ago

and i create this nixpacks.toml file


AnonymousTRIAL

a year ago

[phases.build]
cmds = ['npm run build']

[start]
cmd = 'sleep 3 && npm run prisma migrate deploy && npm run start'