cirandas.net

ref: master

db/migrate/20120818030329_remove_action_tracker_with_target_nil.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class RemoveActionTrackerWithTargetNil < ActiveRecord::Migration
  def self.up
    select_all("SELECT id FROM action_tracker").each do |tracker|
      activity = ActionTracker::Record.find_by(id: tracker['id'])
      if activity && activity.target.nil?
        activity.destroy
      end
    end
  end

  def self.down
    say "this migration can't be reverted"
  end
end