Rails.Vim :RInvert
这个记录迁移的插件有多可靠。我与 Rails 社区中的一些人交谈过,他们告诉我他们对此深信不疑,而其他人则告诉我远离它。任何和所有的想法将不胜感激。
How reliable is this plugin for writing down migrations. Some people in the rails community I have spoken with have told me they swear by it and others are telling me to just stay away. Any and all thoughts will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是惊人的,但我以前也遇到过它不太正常的情况。但是,我强烈建议在第一次运行迁移后执行 rake db:migrate:redo ,以确保向上和向下都能正常工作。即使它只为你写了90%的向下迁移,我也不知道你为什么会远离。
It is phenomenal, but I have had it not work quite right before. However, I would highly recommend doing a
rake db:migrate:redo
after running a migration for the first time anyways to make sure that the up and the down both work. Even if it only writes 90% of the down migration for you, I don't know why you would stay away.从 Rails 3.1 开始,大多数情况下,您不需要编写 down 方法。迁移将有一个 change 方法,Rails 会在发生回滚时自动进行向下迁移。
请参阅:http://edgeguides.rubyonrails.org/migrations.html#writing -您的更改方法
From Rails 3.1 onwards, for most cases, you don't need to write a down method. The migrations will have one change method and Rails automatically does the down migration in case of rollbacks.
Refer: http://edgeguides.rubyonrails.org/migrations.html#writing-your-change-method
如果您只是生成 DDL 更改(添加列等),那么它对我来说一直坚如磐石。但是,如果您要删除列或生成 DML 语句(例如将数据从一个字段复制到另一个字段、转换数据等)... :RInvert 将不会处理这些。但我仍然没有理由不使用它们所生成的内容作为起点。如果您不喜欢 :RInvert 生成的向下迁移,只需删除它,您的情况不会比运行它之前更糟。
If you're just generating DDL changes (adding columns, etc), it has always been rock solid for me. However, if you're removing columns or generating DML statements such as copying data from one field to another, translating data, etc... :RInvert will not handle those. But there's still no reason I can think of to not use what they do generate as a starting point. If you don't like the generated down migration by :RInvert, just delete it and you're no worse off than before you ran it.