Skip to content
This repository
Browse code

Added documentation for #1904

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2157 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 9053c4c83e4ff74e71b7e771a0b58a3cb45e53bc 1 parent 3c3d936
David Heinemeier Hansson authored September 08, 2005
15  activerecord/lib/active_record/migration.rb
@@ -120,6 +120,21 @@ class IrreversibleMigration < ActiveRecordError#:nodoc:
120 120
   #       execute "ALTER TABLE `pages_linked_pages` DROP INDEX `page_id_linked_page_id`"
121 121
   #     end
122 122
   #   end
  123
+  #
  124
+  # == Using the class after changing table
  125
+  #
  126
+  # Some times you'll want to add a column in a migration and populate it immediately after. In that case, you'll need
  127
+  # to make a call to Base#reset_column_information in order to ensure that the class has the latest column data from 
  128
+  # after the new column was added. Example:
  129
+  #
  130
+  #   class MakeJoinUnique < ActiveRecord::Migration
  131
+  #     def self.up
  132
+  #       add_column :people, :salary, :integer
  133
+  #       Person.find(:all).each do |p|
  134
+  #         p.salary = SalaryCalculator.compute(p)
  135
+  #       end
  136
+  #     end
  137
+  #   end  
123 138
   class Migration
124 139
     class << self
125 140
       def up() end

0 notes on commit 9053c4c

Please sign in to comment.
Something went wrong with that request. Please try again.