0

I have successfully imported a PostgreSQL dump and linked it with my Rails application.

When trying to run rails migrations I get this error:

ActiveRecord::NoDatabaseError: FATAL: role "username" does not exist

Where "username" is my account name. I have the following configuration in the database.yml file:

development: &default
  adapter: postgresql
  encoding: unicode
  database: name_of_the_db
  host: localhost
  username: postgres
  password: password
  template: template0

I would like to run the migrations with the postgres user, not creating a new role like in this answer.

Why is username being used as the role for the migrations? I thought the user defined in the database.yml would be used.

How can I config postgres instead?

Edit:

I've made the following changes to my pg_hba.conf file:

# Database administrative login by Unix domain socket
local   all             postgres                                password

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     password

But I've only been able to change the way the user authenticates, not which user is used on the migrations. I can't see how to change that in this file.

Community
  • 1
  • 1
Alan
  • 211
  • 2
  • 13
  • Your problem is called [peer authentication](http://www.postgresql.org/docs/9.1/static/auth-methods.html#AUTH-PEER). – D-side Mar 02 '15 at 14:45
  • Have you made the necessary changes to you pg_hba.conf file? – J Plato Mar 02 '15 at 14:54
  • Thanks for the hints! I'm new to PostgreSQL and didn't know about this. I'll have a look at it. – Alan Mar 02 '15 at 15:18

0 Answers0