在 Heroku 上执行 rake db:migrate 时出错 [英] Error when doing rake db:migrate on Heroku
问题描述
什么时候做
heroku run rake db:migrate
执行所有迁移,然后,最后我总是收到以下消息:
all migrations are performed and then, at the end I always get following message:
/app/vendor/bundle/ruby/1.9.1/bin/rake: 没有那个文件或目录 - pg_dump -i -s -x -O -f/app/db/structure.sql dan79p98fykovu代码>
我无法在 Heroku 上将 pg_dump 添加到 PATH.如何处理?
I can't add pg_dump to PATH on Heroku. How to deal with this?
推荐答案
问题在于,一旦迁移完成,rails 会尝试转储新的 structure.sql
,但由于 而失败pg_dump
不存在.为已部署的应用程序生成新的 structure.sql 毫无意义,因此最好的解决方案是告诉 rails 不要这样做.
The issue is that rails is trying to dump a new structure.sql
once the migration is complete, and failing because pg_dump
is not present. It's pointless to generate a new structure.sql for a deployed app, so the best solution is to tell rails not to.
编辑您的 Rakefile
并覆盖任务.在它的末尾添加以下行应该可以:
Edit your Rakefile
and override the task. Adding the following line at the end of it should do it:
Rake::Task["db:structure:dump"].clear if Rails.env.production?
这篇关于在 Heroku 上执行 rake db:migrate 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!