0

I'm trying to deploy my rails application databse to heroku.

I'm using this command

heroku run rake db:migrate

Ther error im getting is the following

Running rake db:migrate on ⬢ mighty-lowlands-99868... up, run.8184 (Free) rake aborted! Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

My gem file is

source 'https://rubygems.org'

#gem 'ruby', '2.3.4'
gem 'rails', '4.2.5'
#gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
#Authentication Gem -> https://github.com/thoughtbot/clearance
gem 'clearance', '~> 1.16.1'
gem 'bootstrap'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
#Gem for search
#https://github.com/karmi/retire
gem 'tire'
gem 'simple_form', '~> 3.4'
gem 'jquery-turbolinks'
gem "chartkick"

group :development, :test do
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'sqlite3'
  gem 'byebug'
end


group :production do
  gem 'pg'
  gem 'rails_12factor'
end

Any idea what the solution is

Datebasae.yml

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

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

# 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.sqlite3

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

1 Answers1

1

You are using pg in your gemfile for production environment (this is correct). Edit: As commented below, you must specify a supported pg gem version. Use 0.21.0 as 1.0.0 is still not supported.

However, you are using sqlite3 on your databse.yml for production environment.

Moreover, Heroku does not support Sqlite.

To use pg on Heroku, just add the Heroku pg add-on. When you push code, Heroku will replace your database.yml to use the correct database. You don't need the name, username or password. They will be set as environment variables. https://devcenter.heroku.com/articles/rails-database-connection-behavior

Pablo
  • 3,004
  • 1
  • 12
  • 19
  • I get this error now. Even though PG is specified and it's installed. Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). –  Apr 08 '18 at 19:44
  • You must specify a supported pg gem version. Use 0.21.0 as 1.0.0 is still not supported. – Pablo Apr 08 '18 at 19:45
  • Sorted that. This hopefully is my last issue > heroku run rake db:migrate Running rake db:migrate on ⬢ mighty-lowlands-99868... up, run.4332 (Free) rake aborted! PG::ConnectionBad: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? –  Apr 08 '18 at 19:58
  • Check here: https://stackoverflow.com/questions/45336844/error-when-run-migrations-on-heroku-posgresql-with-rails-5 – Pablo Apr 08 '18 at 20:01
  • Great thats know live. –  Apr 08 '18 at 20:19