我有一个名为"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发布于 2015-08-02 13:06:32
这并不是ClearDB本身的问题,看起来您还没有完全脱离PostgreSQL的默认设置。我会查一查:
pg吗?不应该是这样。相反,请确保存在mysql2。一旦您的Heroku应用程序能够正确地连接到ClearDB数据库,您应该能够毫无问题地设置数据库本身:
heroku run rake db:create
heroku run rake db:migrate
heroku run rake db:seedhttps://stackoverflow.com/questions/31768765
复制相似问题