I'm attempting to deploy a Rails 5 app using Capistrano, and I'm hung up on the db:migrate step.
Specifically, when my scripts attempt to run db:migrate I get the error:
ActiveRecord::NoDatabaseError: FATAL: role "admin" does not exist
My database.yml file looks like this for the production block:
production:
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
url: <%= ENV['DATABASE_URL'] %>
and my database_url takes the form of:
postgresql:://mydb_user:mydbuser_pass@localhost/db_name
With mydb_user, mydbuser_pass, and db_name substituted in with my own correct values.
Inside of postgres I can see these permissions on my database:
db_name | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres + postgres=CTc/postgres + mydb_user=CTc/postgres
Which I think means that mydb_user has the permissions necessary for using my database.
Now, the user I'm logged in as during the capistrano deploy does have the username of 'admin', which leads me to believe that I fundamentally don't understand something about postgres roles. Why would my currently logged in user have anything to do with the postgres connection when I've given my username and password via the database url for a specific postgres user I've already created? Is this saying that my ubuntu username needs to match mydb_user in order to login? How do I fix this error specific to rails and database urls with postgres?