Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveRecord::NoDatabaseError FATAL: database "db/development.postgresql" does not exist

I'm building a small app and it was working locally. Then when I went to deploy it on Heroku, this error popped up in my terminal:

remote:        An error occurred while installing sqlite3 (1.3.11), and 

Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     
remote:  !     Detected sqlite3 gem which is not supported on Heroku.
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to pockettheskimm.
remote: 
To https://git.heroku.com/pockettheskimm.git
 ! [remote rejected] master -> master (pre-receive hook declined)

I subsequently read the documentation on Heroku, which told me that I have to use Postgres in my app instead of sqlite3. So I updated my app, swapping out sqlite3 for Postgres:

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.postgresql

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.postgresql

production:
  <<: *default
  database: db/production.postgresql

but now when I run the app locally, I get this error in my browser:

ActiveRecord::NoDatabaseError
FATAL: database "db/development.postgresql" does not exist

Extracted source (around line #661):
659
660
661
662
663
664

        rescue ::PG::Error => error
          if error.message.include?("does not exist")
            raise ActiveRecord::NoDatabaseError.new(error.message, error)
          else
            raise
          end

What can I do to fix this?

like image 886
alicht Avatar asked Dec 25 '22 11:12

alicht


2 Answers

This was the answer that worked for me:

"Have you ran rake db:create && rake db:migrate on development after you've change your database.yml config file? "

credit to https://stackoverflow.com/users/163640/eugen

like image 181
Mr. Rene Avatar answered Dec 27 '22 00:12

Mr. Rene


This works for me:

rails db:create
rails db:migrate
like image 28
Arindam Avatar answered Dec 27 '22 00:12

Arindam