-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logging of Que jobs skipped in migration
- Loading branch information
Showing
2 changed files
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
class MigrateQueJobs < ActiveRecord::Migration[6.0] | ||
def up | ||
QueJob.all.each do |job| | ||
next if job.last_error.present? | ||
|
||
klass = job.job_class.constantize | ||
next unless klass < ApplicationJob | ||
|
||
args = job.args | ||
klass.perform_later(args) | ||
if skip_condition(job) | ||
logger.info "Skipped Que job migration: #{job.inspect}" | ||
else | ||
args = job.args | ||
job.job_class.constantize.perform_later(args) | ||
end | ||
end | ||
end | ||
|
||
def down | ||
raise ActiveRecord::IrreversibleMigration | ||
# raise ActiveRecord::IrreversibleMigration | ||
end | ||
|
||
def logger | ||
@logger ||= Logger.new(Rails.root.join('log', 'que_to_sidekiq_migration.log')) | ||
end | ||
|
||
def skip_condition(job) | ||
job.last_error.present? || !(job.job_class.constantize < ApplicationJob) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# encoding: UTF-8 | ||
DataMigrate::Data.define(version: 20210407140317) | ||
DataMigrate::Data.define(version: 20210405081552) |