无法在Heroku上迁移 [英] Cannot migrate on Heroku

查看:116
本文介绍了无法在Heroku上迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我输入了下面的代码,但是出现错误。我不知道该怎么做。我期待着您的建议。

  $ heroku运行rake db:migrate 

运行`rake db: migrate --trace`附加到终端... up,run.2338
rake流产!
LoadError:libruby.so.2.2:无法打开共享对象文件:没有这样的文件或目录 - /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:在`block in require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport -4.2.1 / lib / active_support / dependencies.rb:240:在`load_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies中。 rb:274:在'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:在'block(2 levels)in require'
/app/vendor/bundle/ruby/2.2 0.0 /宝石/捆绑-1.9.7 / LIB /捆绑/运行。 rb:72:在`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:在'require'
/app/config/application.rb:7:in`< top(required)>'
/ app / Rakefile:4 :在'require'中
/ app / Rakefile:4:在< top(required)>'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/ rake / rake_module.rb:28:`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:在`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:在`block in run'中
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb :176:在`standard_exception_handling'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in`run'
/ app / bin / rake:8:在< main>中


解决方案

您是否尝试过直接从heroku服务器中的bash运行迁移?

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

第一行代码打开bash命令终端,第二行代码像平常一样迁移数据库。 p>




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

  heroku pg:reset DATABASE 
heroku run rake db:migrate

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



希望这可以帮助你。


I'd like to migrate database to production environment on Heroku.

I typed the following code, however I got error. I have no idea what to do. I'm looking forward to your advice. Thank you for your kindness.

$ 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>'

解决方案

Have you tried running migration directly from the bash inside the heroku server? If not, try the following...

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

First line of code opens the bash command terminal and the second one migrates the db as usual.


This would not be the suggested solution. But, in case you DO NOT care about losing data in the database, you can try and reset the database first and try again. Again, don't do this unless you are willing to lose existing data!

heroku pg:reset DATABASE
heroku run rake db:migrate

However you can perform this via bash as before.

Hope this helps you out.

这篇关于无法在Heroku上迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆