是否有一个 rake 任务可以将您的架构版本前进或后退一倍?
当迁移版本号在创建迁移时简单地增加时,这很容易做到:
rake migrate VERSION=097
rake migrate VERSION=098
rake migrate VERSION=099
rake migrate VERSION=100
...但我们现在的迁移号类似于 YYYYMMDDtimeofday。 这并不是一件坏事 - 它可以将迁移版本冲突保持在最低限度 - 但当我有 50 个迁移并且想要一次逐步执行它们时,这是一件麻烦的事情:
rake migrate VERSION=20090129215142
rake migrate VERSION=20090129219783
...等等。 我必须在我面前打开所有迁移的列表,输入版本号以前进一。 有没有更简单的语法,例如:
rake migrate VERSION=NEXT
或
rake migrate VERSION=PREV
?
Back when migration version numbers were simply incremented as you created migrations, it was easy enough to do:
rake migrate VERSION=097
rake migrate VERSION=098
rake migrate VERSION=099
rake migrate VERSION=100
...but we now have migration numbers that are something like YYYYMMDDtimeofday. Not that this is a bad thing - it keeps the migration version collisions to a minimum - but when I have 50 migrations and want to step through them one-at-a-time, it is a hassle:
rake migrate VERSION=20090129215142
rake migrate VERSION=20090129219783
...etc. I have to have a list of all the migrations open in front of me, typing out the version numbers to advance by one. Is there anything that would have an easier syntax, like:
rake migrate VERSION=NEXT
or
rake migrate VERSION=PREV
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您也可以回滚到非常旧的版本。
You can also rollback to a very old version too.
您可以使用
rake db:rollback
回滚到之前的迁移。 不过,看起来您不能只通过一次迁移就可以继续前进。You rollback to the previous migration with
rake db:rollback
. It doesn't look like you can go forward by only one migration though.