ActiveRecord 迁移 - 什么时候引入了 reversible.up/reversible.down 功能?

ActiveRecord migration - when reversible.up/reversible.down feature was introduced?

我目前正在升级旧的遗留 Rails 应用程序,并试图在引入此 reversible.upreversible.down 阻止功能时找到确切的版本号。

class SplitNameMigration < ActiveRecord::Migration
  def change
    add_column :users, :first_name, :string
    add_column :users, :last_name, :string

    reversible do |dir|
      User.reset_column_information
      User.all.each do |u|
        dir.up   { u.first_name, u.last_name = u.full_name.split(' ') }
        dir.down { u.full_name = "#{u.first_name} #{u.last_name}" }
        u.save
      end
    end
  end
end

有人知道吗?

4.0.0 是。

New method reversible makes it possible to specify code to be run when migrating up or down. See the Guide on Migration