mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
Add logging of Que jobs skipped in migration
This commit is contained in:
parent
83706a78e3
commit
687196baed
2 changed files with 16 additions and 9 deletions
|
@ -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
|
||||
|
||||
if skip_condition(job)
|
||||
logger.info "Skipped Que job migration: #{job.inspect}"
|
||||
else
|
||||
args = job.args
|
||||
klass.perform_later(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
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
# encoding: UTF-8
|
||||
DataMigrate::Data.define(version: 20210407140317)
|
||||
DataMigrate::Data.define(version: 20210405081552)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue