Rails 3 生成迁移 - 没有向上或向下方法
刚刚学习 Rails,正在进行迁移,一切都从逻辑上开始,直到我在代码中遇到了一些奇怪的事情;
rails generate migration AddRegionToSupplier
上面生成了一个迁移文件,其中仅包含“def change”方法。
我用谷歌搜索了一下,发现这正是应该发生的事情;
http://guides.rubyonrails.org/migrations.html
我希望它会生成“def up”并且“def down”方法,以便回滚迁移。我在这一代人中是否做错了什么,或者我错过了一些明显的事情?
Just learning rails, am on to migrations and it all started off pretty logically until I hit something odd going on in the code;
rails generate migration AddRegionToSupplier
The above produces a migration file with only a "def change" method in it.
I googled this and found that this is exactly what is supposed to happen;
http://guides.rubyonrails.org/migrations.html
I would have expected it to generate a "def up" and "def down" method, so that the migration could be rolled back. Have I done something wrong in the generation or am I missing something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您粘贴的链接:
因此,看起来您不必担心
def self.down
,因为 Rails 现在足够智能,知道如何将其回滚。From the link you pasted:
So it looks like you don't have to worry about having a
def self.down
as Rails is now smart enough to know how to roll it back.