将数据库迁移到Heroku时出现问题

时间:2011-08-04 08:03:19

标签: database deployment heroku rake migrate

尝试将数据库迁移到Heroku时,我得到以下内容(假设我正在使用gem 'sqlite3', '1.3.3'

$ heroku rake db:migrate
(in /app)
rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:Ta
skLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:R
ake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (req
uired)>'
/app/.bundle/gems/ruby/1.9.1/gems/rdoc-3.9.1/lib/rdoc/task.rb:37:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/rdoc-3.9.1/lib/rdoc/task.rb:37:in `<top (requi
red)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.r
ake:2:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.r
ake:2:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `load'

/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `block
 in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `<top (
required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in
 `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in
 `initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:139:in
 `load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:in
`method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'

我该如何解决这个问题?

感谢。

1 个答案:

答案 0 :(得分:0)

Rake aborted! Uninitialized constant Rake::DSL on Heroku

I have a blog post about this here。有两种方法可以做到这一点:

仅使用旧版本的rake:

使用$ gem list查看您当前的Rake版本。查看您拥有的rake版本,并将其全部删除,0.8.7除外。您可以使用gem uninstall rake -v=0.9.1或您需要删除的任何版本删除宝石。

或者只是在rake文件中添加一个衬垫:

除非您必须使用旧版本的Rake,否则将此行require 'rake/dsl_definition'添加到Rails的应用程序Rakefile中会更容易。

require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'