Deploy rails app with MySQL to Heroku using AddAdd addDDD

I have a Rails application called "enrollment_app" that initializes and populates all tables in a database using a MySQL sample file. I built my app, added some migrations and pushed my app to Heroku. However, since Heroku uses Postgres, I need a way to make my MySQL database compatible with Heroku, so I use the ClearDB addon.

When I try to open the app, I get the message:

Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

      

So I checked the logs and saw this error:

PG::UndefinedTable: ERROR:  relation "enrollments" does not exist

      

I am following this tutorial , but apparently I don’t know how to make ClearDB look like my local MySQL database as I am getting this error above. How can I make the equivalent of rake db:seed

the MySQL seed file rake db:migrate

for the production ClearDB database too?

Updated - Gemfile:

source 'https://rubygems.org'

gem 'rails', '4.2.1'
gem 'mysql2'
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
gem 'bootstrap-sass', '~> 3.3.5'
gem 'bootswatch-rails'
gem 'ransack'
gem 'jquery-turbolinks'
gem 'kaminari'
gem 'bootstrap-kaminari-views'
gem 'jquery-ui-rails'
gem 'espinita'
gem 'mysqltopostgres', git: "https://github.com/maxlapshin/mysql2postgres.git"

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'rspec-rails'
  gem 'launchy'
  gem 'pry'
  gem 'pry-nav'
  gem 'shoulda-matchers'
  gem 'factory_girl_rails'
  gem 'capybara'
  gem 'newrelic_rpm'
  gem 'poltergeist'
  gem 'database_cleaner'
end

group :production do
  gem 'rails_12factor'
end

      

+3


source to share


1 answer


This is not a problem with ClearDB per se, it looks like you are not completely divorced from the default PostgreSQL. I would check:

  • is there pg

    defined in your Gemfile? it shouldn't be. Make sure it is present instead mysql2

    .
  • Have you installed the Heroku ClearDB add-on for this application and made it the default database your application will use? Have you deleted your Heroku Postgres database? See here for details .


Once your Heroku application is able to properly connect to the ClearDB database, you should be able to configure the database yourself without any problem:

heroku run rake db:create
heroku run rake db:migrate
heroku run rake db:seed

      

+3


source







All Articles