【问题标题】:Multiple Migrations whit same Version Number on Deployng Rails to Heroku将 Rails 部署到 Heroku 时使用相同版本号进行多次迁移
【发布时间】:2013-07-21 16:46:24
【问题描述】:

我多次遇到这个问题,我搜索了很多并没有找到任何解决方案,我的问题是:

运行后

git push heroku push master

当我跑步时

heroku run rake db:migrate

我得到这个错误:

Multiple migrations have the version number 20130615132808

我通过这个问题搜索并发现了这个:

rails database migration - multiple migrations have the version number x

但是当执行git rm时出现一些选项我不太了解git所以我需要解决这个问题,我在localhost中删除档案但问题仍然存在,非常感谢帮助。

【问题讨论】:

  • 您不了解哪些选项?请发布您正在执行的完整的git rm ...,以及您得到的和不理解的内容。还有版本号是怎么冲突的,你是不是手动重命名了迁移文件?
  • 嗯我如何在部署到 heroku 后重命名迁移?当我执行 git rm 出现这个usage: git rm [options] [--] <file>... -n, --dry-run dry run -q, --quiet do not list removed files --cached only remove from the index -f, --force override the up-to-date check -r allow recursive removal --ignore-unmatch exit with a zero status even if nothing matched

标签: ruby-on-rails ruby-on-rails-3 heroku ruby-on-rails-3.1 ruby-on-rails-3.2


【解决方案1】:

只需重命名带有重复时间戳的文件(最后一位加 1),然后添加、提交和推送文件。当你再次运行heroku run rake db:migrate 时,一切都会变得美好。

对于未来,请记住不要手动复制和重命名迁移(这样您就不会得到重复的版本号)

【讨论】:

    【解决方案2】:

    当您复制粘贴多个“rails generate”命令以生成迁移时,可能会发生这种情况。生成的迁移可能具有相同的时间戳。如果您分别输入(或复制粘贴)它们,它们将具有不同的时间戳。

    发生这种情况时,您可以简单地重命名 db/migrate 下的迁移文件以包含不同的时间戳。

    【讨论】:

      猜你喜欢
      • 2014-10-27
      • 2019-08-28
      • 2016-10-07
      • 1970-01-01
      • 2013-02-25
      • 1970-01-01
      • 1970-01-01
      • 2020-08-30
      • 2018-10-31
      相关资源
      最近更新 更多