Inexplicably, when I run the following migration code using rake, the column, but not the values, appear in the MySQL DB table:
class AddTypeToItems < ActiveRecord::Migration
def self.up
add_column :items, 'type', :string, :limit => 100, :null => false
Item.find_by_name('YUMMY_JUICE').update_attribute(:type, 'Juice')
Item.find_by_name('TASTY_JUICE').update_attribute(:type, 'Juice')
Item.find_by_name('NASTY_JUICE').update_attribute(:type, 'Juice')
end
def self.down
remove_column :items, 'type'
end
end
I actually have to rollback the migration, then run it again (twice in total) for the values to appear. What is going on?