"You have no tables" in my Postgres database yet i see volume increasing.

swan-of-bodom
PRO

a year ago

I have a nodejs app running which stores data in a postgres database on railway which is connected. When i go to the database i see the following:

"You have no tables"

And i cannot see any data. Does it usually take a long time to populate the postgres database? I re-deployed the node app 1 hour ago, but it still says its connected.

Solved

13 Replies

unicodeveloper
PRO

a year ago

Hi, when the app was deployed, did you configure the app to run your database migrations on startup?

In the linked project, I can see about 4 database services. Which of the Postgres services are you referring to?


Status changed to Awaiting User Response Railway about 1 year ago


swan-of-bodom
PRO

a year ago

Hi, i'm referencing all the apps actually, which are all currently identical (the same nodejs app).

When the app was deployed on Railway i believe i created the Postgres database first and then added the DATABASE_URL variable before deploying everything. On the UI it shows that it's linked correctly to each database, and you can see on the image attached.

Also, on the deployed logs, you can see that it did indeed create a table (not sure if it's asqlite or postgres table (see image attached showing 1 app only). The reason is that if DATABASE_URL is not set, then the app will create a SQLite table. However, I can see the pg database gaining volume, so it indicates that it is indeed connected).

Thanks!


Status changed to Awaiting Railway Response Railway about 1 year ago


unicodeveloper
PRO

a year ago

From what I can see, your env variables are not linked properly to the database url.

For example, you are doing something like scroll-pg.DATABASE_URL instead of scroll-factory.DATABASE_URL . It should be the name of your service. Maybe you renamed your service and didn't update it in the env variable reference


Status changed to Awaiting User Response Railway about 1 year ago


swan-of-bodom
PRO

a year ago

I am confused sorry, i don't understand what you mean. Let's take scroll for example.

I have 1 nodejs app, and 1 postgres database.

I cannot rename the postgres "scroll-factory" as i get an error since the name already exists (see image attached).

The name of the postgres database is "scroll-pg" which is exactly what is in the .env variable of the nodejs "scroll-factory" (see image attached).

Also on the UI it shows they are connected successfully, so i believe the ENV variables are correct.

Could it be due to the fact that it's a monorepo and i did not set a root directory for this package? I only edited the deploy command to start the service, or else no packages in root get installed.



Status changed to Awaiting Railway Response Railway about 1 year ago


swan-of-bodom
PRO

a year ago

Also from the deploy logs of scroll-factory we can see that it is indeed using the postgres database:

Attachments


unicodeveloper
PRO

a year ago

At what point does your migrations run? I just checked again and I understand what you are saying concerning the services names. Seems they are correct.


Status changed to Awaiting User Response Railway about 1 year ago


swan-of-bodom
PRO

a year ago

It runs as soon as i run pnpm run start in our case since its a monorepo i wrote a script on the package.json for each service, so in this case: pnpm run start:factory-v2 scroll


Status changed to Awaiting Railway Response Railway about 1 year ago


unicodeveloper
PRO

a year ago

Can you see anything or metadata about the migrations show up in the logs after each deploy?


Status changed to Awaiting User Response Railway about 1 year ago


swan-of-bodom
PRO

a year ago

I am not sure sorry, all i can find is the following:

12:16:07 PM INFO build Using Postgres database scroll-pg.railway.internal:5432/railway (from DATABASE_URL env var)

Oct 10 14:16:07

12:16:07 PM INFO build Using 'scroll-factory_18e2a0e5' database schema for indexed tables (from RAILWAY_DEPLOYMENT_ID env var)


Status changed to Awaiting Railway Response Railway about 1 year ago


swan-of-bodom
PRO

a year ago

When i go to the postgres deploy, i see all errors also i think (attached)

Attachments


unicodeveloper
PRO

a year ago

I just went through the error logs from your db. Something is wrong with your migration schema and relations. And that's preventing it from running successfully.

Error: relation "public.kysely_migration" does not exist at character 15.

So please fix that. See attached.

Attachments


Status changed to Awaiting User Response Railway about 1 year ago


swan-of-bodom
PRO

a year ago

I just went through the error logs from your db. Something is wrong with your migration schema and relations. And that's preventing it from running successfully.

Error: relation "public.kysely_migration" does not exist at character 15.

So please fix that. See attached.

thank you, i will have look


Status changed to Awaiting Railway Response Railway about 1 year ago


swan-of-bodom
PRO

a year ago

Hi, we can close this.

Railway's SQL viewer unfortunately only looks for tables in the public schema and our app tables are in a deployment-specific schema.

Thanks for your help!


Status changed to Solved brody 12 months ago


"You have no tables" in my Postgres database yet i see volume increasing. - Railway Help Station