When I do rake db:migrate, I get the error,below i have attached my databse.yml and my gem file, tried all the stuff on the internet but the error did'nt get resolved!
rake aborted!
LoadError: cannot load such file -- mysql2
development:
adapter: mysql2
encoding: utf8
database: demo_project_development
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock
host: localhost
test:
adapter: mysql2
database: demo_project_test
database: db/development.mysql2
username: root
password: root
pool: 5
timeout: 5000
production:
adapter: postgresql
database: demo_project_production
pool: 5
timeout: 5000
Gemfile source 'https://rubygems.org' gem 'rails', '4.2.6' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc
group :production do
gem 'pg', '0.20'
gem 'rails_12factor'
end
group :test do
gem 'byebug'
gem 'mysql2', '>= 0.3.13', '< 0.5'
end
gem 'spring'
gem 'devise'
gem "cancan"
gem 'ckeditor', '4.1.3'
gem "nested_form"
gem "paperclip", "~> 5.0.0"
gem 'bootstrap-sass', '~> 3.3.6'
gem 'kaminari'
gem 'ratyrate'
gem 'thinking-sphinx', '~> 3.3.0'
gem 'delayed_job_active_record'
gem 'rails-api'
gem 'active_model_serializers', '~> 0.10.6'
group :development do
gem 'web-console', '~> 2.0'
gem 'mysql2', '>= 0.3.13', '< 0.5'
end
Below is my application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
module DemoProject
class Application < Rails::Application
config.active_record.raise_in_transactional_callbacks = true
config.active_job.queue_adapter = :delayed_job
config.api_only = false
end
end
config/envoirment.rb
require File.expand_path('../application', __FILE__)
Rails.application.initialize!
boot.rb
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
heroku run rake db:migrate? And as far as I know, Heroku does not support mysql, it only supports Postgresql. - Sajan