【问题标题】:rake aborted when running heroku run rake db:migrate运行 heroku run rake db:migrate 时 rake 中止
【发布时间】:2014-03-21 07:56:23
【问题描述】:

我在自己的数据库上进行了一些本地迁移,当我尝试在 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:reset DATABASE 并再次迁移,仍然给我这个错误

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

【问题讨论】:

  • 这个Multiple migrations have the name CreateUsers 看起来很有帮助。您是否有两个具有相同类名的迁移?
  • 20140219235208_create_users.rb 20140220063644_add_years_to_users.rb 20131225101255_add_password_digest_to_users.rb 20131225095857_add_index_to_users_email.rb 20140103210551_add_remember_token_to_users.rb这些都是迁移跨度>
  • 我说的是类名,不是文件名。查看文件内部:其中两个文件开头是否有class CreateUsers?他们都需要有一个独特的类。
  • 不,他们没有。每个人都有一个独特的班级
  • 请您在命令行中运行它,在您的 rails 项目文件夹中,然后将结果发布到您的问题的编辑中吗? tail -n 100 db/migrate/*

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


【解决方案1】:

This Multiple migrations have the name CreateUsers 看起来您有两个具有相同类名 CreateUsers 的迁移

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

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

【讨论】:

    【解决方案2】:

    我这样解决了这个问题: 1.检查 db/migrate 文件夹。您将看到至少两个具有相同名称的文件。 2.删除旧文件。使用 git rm db/migrate/"文件名" 3.推送到git

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

    4.push 到远程仓库并部署到 Heroku:

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

    【讨论】:

      猜你喜欢
      • 2014-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-04
      • 2013-03-08
      • 2017-07-30
      • 2017-01-07
      相关资源
      最近更新 更多