Rails 3.1 迁移删除迁移文件名中的时间戳
我正在尝试将应用程序从 Rails 3.0.7 升级到 3.1.1。当我尝试在 3.1.1 下运行迁移时,会生成迁移文件,但没有前导时间戳。例如:
$ rails g migration add_foo_to_users foo:boolean
invoke active_record
create db/migrate/_add_foo_to_users.rb
生成的文件的内容看起来是正确的(使用新的酷更改方法),但迁移文件似乎应该命名为 db/migrate/20111012002448_add_foo_to_users.rb。
我怀疑我错过了一些简单的东西,但花了整个周末试图弄清楚它是什么。搜索显示我没有发现任何有用的信息。在此之前,迁移一直在进行,因此我升级步骤中的某些内容似乎破坏了它。任何关于去哪里寻找的建议将不胜感激。谢谢。
I am trying to upgrade an application from Rails 3.0.7 to 3.1.1. When I try to run a migration under 3.1.1, the migration file gets generated but without the leading timestamp. For example:
$ rails g migration add_foo_to_users foo:boolean
invoke active_record
create db/migrate/_add_foo_to_users.rb
The contents of the generated file look correct (with the new cool change method), but the migration file seems like it should be named more like db/migrate/20111012002448_add_foo_to_users.rb.
I suspect that I am missing something simple, but spent all weekend trying to figure out what it is. Search shows nothing helpful that I found. Migrations have been working all along before this, so something in the steps I took to upgrade seems to have broken it. Any suggestions of where to look would be appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经追踪到这个问题并在also_migrate的GateGuru分支中修复了它。拉取请求正在等待合并回also_migrate。
对于在此期间遇到此问题的任何人,拉取请求位于: https://github.com/ winton/also_migrate/pull/10
您还可以通过 Bundler 从我的 fork 安装来解决该问题:
I have traced this issue down and fixed it in the GateGuru fork of also_migrate. A pull request is pending for merge back into also_migrate.
For anyone bitten by this in the interim, the pull request is at: https://github.com/winton/also_migrate/pull/10
You can also install from my fork via Bundler to fix the issue:
以防万一有人遇到同样的问题后来到这里。将整个应用程序复制到另一个目录,并与新的 Rails 应用程序的全新安装进行比较后,我将范围缩小到了also_migrate gem 的配置块。当我注释掉此配置的行时,迁移文件已正确生成。取消注释相同的行会重新创建错误。
Just in case anyone ends up here after hitting the same problem. After copying the entire application to another directory, and comparing to a clean install of a new Rails application, I narrowed this down to the configuration block for the also_migrate gem. When I comment out the lines for this configuration, the migration files were generated properly. Uncommenting the same lines recreates the error.