class SetCreatedByField < ActiveRecord::Migration def self.up Patch.find(:all, :conditions => "created_by IS NULL").each do |p| p.created_by = User.find_by_login('admin').id p.save end end def self.down end end