lib/good_job/job.rb in good_job-1.10.1 vs lib/good_job/job.rb in good_job-1.11.0

- old
+ new

@@ -217,10 +217,25 @@ rails db:migrate DEPRECATION end + if column_names.include?('concurrency_key') + good_job_args[:concurrency_key] = active_job.good_job_concurrency_key if active_job.respond_to?(:good_job_concurrency_key) + else + ActiveSupport::Deprecation.warn(<<~DEPRECATION) + GoodJob has pending database migrations. To create the migration files, run: + + rails generate good_job:update + + To apply the migration files, run: + + rails db:migrate + + DEPRECATION + end + good_job = GoodJob::Job.new(**good_job_args) instrument_payload[:good_job] = good_job good_job.save! @@ -262,18 +277,23 @@ # @return [Boolean] def executable? self.class.unscoped.unfinished.owns_advisory_locked.exists?(id: id) end + def active_job_id + super || serialized_params['job_id'] + end + private # @return [ExecutionResult] def execute params = serialized_params.merge( "provider_job_id" => id ) GoodJob::CurrentExecution.reset + GoodJob::CurrentExecution.active_job_id = active_job_id ActiveSupport::Notifications.instrument("perform_job.good_job", { good_job: self, process_id: GoodJob::CurrentExecution.process_id, thread_name: GoodJob::CurrentExecution.thread_name }) do value = ActiveJob::Base.execute(params) if value.is_a?(Exception) handled_error = value