我想知道那些是什么意思:
class ChangeTimeColumns < ActiveRecord::Migration
def self.up
end
def self.down
end
end
有时 Rails 只是像这样创建一个迁移:
class ChangeTimeColumns < ActiveRecord::Migration
def change
end
end
如有任何澄清,我们将不胜感激。
最佳答案
如果您犯了错误,您可以撤消迁移。
rake db:rollback #this will rollback the most recent migration
rake db:rollback STEP=3 #this will rollback 3 of them
我将 self.up 和 self.down 添加到我的所有迁移中,如果存在无法逆转的迁移,则不能包含 down 或在 down 中引发异常。查看本指南中的第 4.1 节 ====> http://guides.rubyonrails.org/migrations.html#using-the-up-down-methods
关于ruby-on-rails - Rails 迁移 - self.up 和 self.down 有什么意义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11140857/