我有一个名为“enrollment_app”的 Rails 应用程序,它使用 MySQL 种子文件初始化和填充数据库中的所有表。我构建了应用程序,添加了一些迁移并将我的应用程序推送到 Heroku。然而,由于 Heroku 使用 Postgres,我需要一种方法让我的 MySQL 数据库与 Heroku 兼容,所以我使用 ClearDB 插件。
但是,当我尝试打开该应用程序时,我收到以下消息:
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.
所以,我检查了日志并看到了这个错误:
PG::UndefinedTable: ERROR: relation "enrollments" does not exist
我一直在关注本教程,但显然我不知道如何使 ClearDB 看起来像我的本地 MySQL DB,因为我在上面遇到了那个错误。如何rake db:seed
对 MySQL 种子文件和rake db:migrate
生产 ClearDB 数据库进行等效操作?
更新 - 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