无法在Heroku上迁移

时间:2015-08-03 06:23:56

标签: ruby-on-rails postgresql heroku migrate

我想在Heroku上将数据库迁移到生产环境。

我输入以下代码,但是我收到了错误。我不知道该怎么做。我期待着你的建议。谢谢你的好意。

$ heroku run rake db:migrate

Running `rake db:migrate --trace` attached to terminal... up, run.2338
rake aborted!
LoadError: libruby.so.2.2: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.2/lib/pg_ext.so
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.2/lib/pg.rb:4:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `block in require'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
/app/config/application.rb:7:in `<top (required)>'
/app/Rakefile:4:in `require'
/app/Rakefile:4:in `<top (required)>'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/app/bin/rake:8:in `<main>'

2 个答案:

答案 0 :(得分:3)

您是否尝试过直接从heroku服务器中的bash运行迁移?如果没有,请尝试以下方法......

heroku run bash --app your_app_name_goes_here
bundle exec rake db:migrate

第一行代码打开bash命令终端,第二行代码照常迁移数据库。

这不是建议的解决方案。但是,如果您不关心丢失数据库中的数据,您可以先尝试重置数据库,然后重试。同样,除非您愿意丢失现有数据,否则不要这样做!

heroku pg:reset DATABASE
heroku run rake db:migrate

但是你可以像以前一样通过bash执行此操作。

希望这可以帮助你。

答案 1 :(得分:1)

您可以使用heroku run:detached在后​​台运行dyno。与heroku运行不同,这些dynos会将其输出发送到您的日志而不是控制台窗口。您可以使用heroku日志查看这些命令的输出:
$ heroku run:detached rake db:migrate Running rake db:migrate... up, run.2 Use 'heroku logs -p run.2' to view the log output.