Postgres Db is empty of tables

I am a novice to Dbs. I just rebuilt and deployed my app. However, the db wasn’t responding, so I:

  • connected the db.

  • ran \l to find my db.

  • connected to the db using \c [name]

  • used \dt to get a list of database tables and it only returned:

                   List of relations
    

    Schema | Name | Type | Owner
    ----------±----------------±------±---------------------
    public | spatial_ref_sys | table |
    topology | layer | table |
    topology | topology | table |

Non of the expected tables are listed above. What am I doing wrong?

Thank you

Hi @Kay2dan,

I’ve taken a look at your account, and I see there were two databases that were deleted, and they had similar names to your current database. One database, created in November, was deleted about 10.5 hours ago. Your second was created about 10.5 hours ago, and deleted about 3 hours ago. Your current database was created about 3 hours ago.

If you’re expecting to see the previous data, it looks like you may be unintentionally deleting your databases. Can you give me more information about what actions you were taking when rebuilding and deploying your app?

Additionally, was there data in the first database that you would like to restore? We still have a backup from about 30 minutes before the database was deleted, and I can help you restore it.

Thank you @dan for getting back to me quickly.

No, the dbs were deleted intentionally. I am confused why the new db does not have the tables that my local dev build should have. I deleted the previous two dbs because I suspected that the migrations were not being applied. However, upon a new build of both the client & db, the app is still not able to connect to the db. This is where I am confused and not sure how to proceed as I can see the db url in the environment tab in the app service, however how do I make it communicate correctly with the db. It appears to me that the postgres db is not being correctly created (as no tables were founds when I shelled into it).

Could you guide me how to troubleshoot this & get the app to work correctly with the db.

Thank you so much.

The database itself is getting created correctly, since we can shell into it and ask for a list of tables.

It sounds like your application has a bootstrap or migration process that populates a new database with its tables, and that your local dev build has done this bootstrap process with your local dev database.

For your Render database, you will have to do the same thing to populate it with your tables. It looks like your web service has the correct database credentials in its environment variables, so it should be able to do the bootstrapping. The process to do that will be specific to your application, however, so I’m unable to assist with that.

Good luck!

1 Like