Reputation: 2346
I'm running a large update on my models (generating a random public_id) and it's taking forever on heroku.
Running the command:
Episode.where(public_id: nil).find_each do |e|
e.set_public_id
e.save
end
Is taking forever and it's a black box. Running it locally I could see the progress through database commits.
Is there a way to see what's going on? Is there a different way I should be running this command?
Upvotes: 0
Views: 854
Reputation: 4639
Make a rake task & use the logger to inform whats happening
#lib/tasks/episode.rake
require 'rake'
namespace :episode do
desc "your description"
task :update => :environment do
Episode.where(public_id: nil).find_each do |e|
Rails.logger.info "updating #{e} ..."
e.set_public_id
e.save
end
end
end
Then run it
heroku run rake episode:update
and you can tail the logs in another terminal window with
heroku logs -t
Upvotes: 2