mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 17:55:55 +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]
|
class MigrateQueJobs < ActiveRecord::Migration[6.0]
|
||||||
def up
|
def up
|
||||||
QueJob.all.each do |job|
|
QueJob.all.each do |job|
|
||||||
next if job.last_error.present?
|
if skip_condition(job)
|
||||||
|
logger.info "Skipped Que job migration: #{job.inspect}"
|
||||||
klass = job.job_class.constantize
|
else
|
||||||
next unless klass < ApplicationJob
|
args = job.args
|
||||||
|
job.job_class.constantize.perform_later(args)
|
||||||
args = job.args
|
end
|
||||||
klass.perform_later(args)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
DataMigrate::Data.define(version: 20210407140317)
|
DataMigrate::Data.define(version: 20210405081552)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue