0

I created a new rails project and did few configuration changes in database.yml. Then had to create the database using the command rake db:create inorder to continue developing the application but I get the error below.

Els-MacBook-Pro:eshop el$ rake db:create
warning ../../package.json: No license field                                                                 
FATAL:  role "eshop" does not exist
Couldn't create 'eshop_development' database. Please check your configuration.
rake aborted!
PG::ConnectionBad: FATAL:  role "eshop" does not exist

Tasks: TOP => db:create
(See full trace by running task with --trace)
Els-MacBook-Pro:eshop el$ 

I will also post the contents of my database.yml below:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  host: localhost
  database: eshop_development
  username: eshop
  password: eshop

test:
  <<: *default
  host: localhost
  database: eshop_test
  username: eshop
  password: eshop

production:
  <<: *default
  database: eshop_production
  username: eshop
  password: <%= ENV['ESHOP_DATABASE_PASSWORD'] %>

enter image description here

I will be grateful if someone can help me figure out why I cannot create a db. I have read all types of solutions and none seems to be working. Thanks.

5
  • did you already create role eshop on your postgresql? Commented Jun 27, 2021 at 6:29
  • Yes I think so. If not how do I create that. Because when I created the new rails app few days back, the error I was getting was unable to connect to server I came back to continue work and I now get this error of eshop does not exist Commented Jun 27, 2021 at 7:10
  • maybe this kb.objectrocket.com/postgresql/… Commented Jun 27, 2021 at 7:23
  • you should check the role if it exist Commented Jun 27, 2021 at 7:23
  • 1
    @dedypuji Thanks. I created the role and was able to create the DB Commented Jun 27, 2021 at 7:42

2 Answers 2

3

In your database.yaml you need to add a port: 5432, and then Try rails db:create, as rake has been deprecated.

Sign up to request clarification or add additional context in comments.

Comments

0

create a role in your postrgesql database named 'eshop'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.