dimanche 6 août 2017

Unable to deploy rails app on Heroku. Postgresql not detected

I have developed a rails app Todo List but when trying to deploy it on Heroku. I see the database needs to be changed to PostgreSQL. I tried with following changes in my files. But I am unable to trace what could be the possible failure. Searched on various Q&A but couldn't find a solution. Is there any other way deploying on Heroku?

Gemfile:

group :development, :test do
  gem 'sqlite3'
end

group: production do
  gem 'pg'
end

database.yml:

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

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

test:
<<: *default
database: DB/test.sqlite3

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

Commands:

$ bundle install 
$ rake db:migrate
rake aborted!
ActiveRecord::NoDatabaseError: FATAL:  database "db/development.sqlite3" does not exist
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:705:in `rescue in connect'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:701:in `connect'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/connection_handling.rb:88:in `connection'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/schema_migration.rb:20:in `table_exists?'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/schema_migration.rb:24:in `create_table'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/migration.rb:1125:in `initialize'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/migration.rb:1007:in `new'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/migration.rb:1007:in `up'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/migration.rb:985:in `migrate'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
    /Users/Jeevan/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'
    PG::ConnectionBad: FATAL:  database "db/development.sqlite3" does not exist

Aucun commentaire:

Enregistrer un commentaire