运行heroku时rake aborted运行rake db:migrate

时间:2014-02-20 11:40:49

标签: ruby-on-rails ruby database heroku migration

我在自己的数据库上进行了一些本地迁移,当我尝试在heroku上迁移时,它终止了我的终止:

 Multiple migrations have the name CreateUsers
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:978:in `validate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:876:in `initialize'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:764:in `new'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:764:in `up' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:742:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
 (See full trace by running task with --trace)

我试过heroku pg:重置DATABASE并再次迁移,仍然给我这个错误

在本地运行数据库似乎没问题。有什么建议吗?

2 个答案:

答案 0 :(得分:0)

This Multiple migrations have the name CreateUsers看起来您有两次具有相同类名CreateUsers

的迁移

如果成功,请在本地运行所有migrations,然后再次尝试重新推送heroku

希望它能解决你/这个问题

答案 1 :(得分:0)

我用这种方式解决了这个问题: 1.检查db / migrate文件夹。您将看到至少两个具有相同名称的文件。 2.删除旧文件。使用git rm db / migrate /&#34;文件名&#34; 3.push to git

$git add -A
$git commit -m ""
$git checkout master

4.赶到远程存储库并部署到Heroku:

$ bundle exec rake test
$ git push
$ git push heroku
$ heroku run rake db:migrate