Database Connections

Deploy failed for a Rails app with this error:

Nov 19 01:33:20 PM Caused by:
Nov 19 01:33:20 PM ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation “schedules” does not exist (ActiveRecord::StatementInvalid)

I connected my database to my service using the internal database URL in the environment variables, which matches my render.yaml with DATABSE_URL. Is there somewhere else I need to check the connection? Both the service and the database are in the same region, Ohio (US East).

Hi there,

Have you run any migrations on your database to create your tables?

Regards,

Keith
Render Support, UTC+10 :australia:

In my render-build.sh I have this:

bundle exec rake db:create
bundle exec rake db:schema:load DISABLE_DATABASE_ENVIRONMENT_CHECK=1

I was able to build and deploy the service with no errors. But there’s no data displayed and I thought the database was connected properly.

EDIT: I got it figured out!

Hi there,

It looks like you updated your build script just to have bundle exec rake db:migrate. Did this help? This is what I would recommend to have in your build script. You for sure don’t need bundle exec rake db:create as your database already exists. bundle exec rake db:schema:load you don’t want to be running every build.

Regards,

Keith
Render Support, UTC+10 :australia: