File: //usr/local/rvm/gems/ruby-2.5.9/doc/activerecord-6.1.4.1/ri/ActiveRecord/Migration/reversible-i.ri
U:RDoc::AnyMethod[iI"reversible:ETI"'ActiveRecord::Migration#reversible;TF:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [ I"OUsed to specify an operation that can be run in one direction or another. ;TI"KCall the methods +up+ and +down+ of the yielded object to run a block ;TI""only in one given direction. ;TI"LThe whole block will be called in the right order within the migration.;To:RDoc::Markup::BlankLine o;
; [I"HIn the following example, the looping on users will always be done ;TI"Mwhen the three columns 'first_name', 'last_name' and 'full_name' exist, ;TI"even when migrating down:;T@o:RDoc::Markup::Verbatim; [I"=class SplitNameMigration < ActiveRecord::Migration[6.0]
;TI" def change
;TI"1 add_column :users, :first_name, :string
;TI"0 add_column :users, :last_name, :string
;TI"
;TI" reversible do |dir|
;TI") User.reset_column_information
;TI" User.all.each do |u|
;TI"M dir.up { u.first_name, u.last_name = u.full_name.split(' ') }
;TI"I dir.down { u.full_name = "#{u.first_name} #{u.last_name}" }
;TI" u.save
;TI" end
;TI"
end
;TI"
;TI"; revert { add_column :users, :full_name, :string }
;TI" end
;TI"end;T:@format0:
@fileI"#lib/active_record/migration.rb;T:0@omit_headings_from_table_of_contents_below00I"helper;T[ I"();T@*FI"Migration;TcRDoc::NormalClass00