Report this

What is the reason for this report?

Hi guys im new in Digital Ocean and im trying to deploy a personal project. My issue happens when i try to migrate into a production database in a droplet rails app

This is my database.YML

  • default: &default

  • adapter: postgresql

  • encoding: unicode

  • pool: <%= ENV.fetch(“RAILS_MAX_THREADS”) { 5 } %>

  • production:

  • <<: *default

  • secret_key_base: <%= ENV[“SECRET_KEY”] %>

  • username: <%= ENV[“DATABASE_USER”] %>

  • password: <%= ENV[“DATABASE_PASSWORD”] %>

  • database: <%= ENV[“DATABASE”] %>

  • host: <%= ENV[“DATABASE_HOST”] %>

these are the steps im following

  1. Cd Into rails app on VM
  2. rails s -d -b 0.0.0.0 RAILS_ENV=production

At this point the production server is “online”

then i want to get migrations by running this:

  1. rake db:migrate RAILS_ENV=production

and this is the issue:

Caused by:PG::ConnectionBad: FATAL: database “root” does not exist

Rails -v 6.0.3.4

Ruby -v 2.7.1



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
0

Hi there,

The error that you are getting indicates that you’ve defined root as the database that you want to use, but that database does not seem to exist.

What I could suggest is:

  • Connect to your Managed database with any SQL client like Table Plus or DBever.
  • Create a new database for your project.
  • Then use that new database in your env variables.

For more information on how to do that you can follow the steps here:

https://docs.digitalocean.com/products/databases/postgresql/how-to/manage-users-and-databases/

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.