Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9436: reset_column_information_in_migration_fixed_doc.diff

File reset_column_information_in_migration_fixed_doc.diff, 1.1 kB (added by sur, 1 year ago)

updated doc for migrations on reset_column_information

  • activerecord/lib/active_record/migration.rb

    old new  
    149149  # 
    150150  # == Using a model after changing its table 
    151151  # 
    152   # Sometimes you'll want to add a column in a migration and populate it immediately after. In that case, you'll need 
    153   # to make a call to Base#reset_column_information in order to ensure that the model has the latest column data from 
    154   # after the new column was added. Example: 
    155   # 
     152  # Whenever you add, remove or change a column, you should immediately reset the relative model's column information 
     153  # by making a call to Base#reset_column_information in order to ensure that the model has latest column data and can  
     154  # be used to populate data in the same or successive migrations from after the new column was added, removed or changed. 
     155  # Example: 
     156  #  
    156157  #   class AddPeopleSalary < ActiveRecord::Migration 
    157158  #     def self.up 
    158159  #       add_column :people, :salary, :integer