From f6e5c24436737aa66c8531abc9b389c4a3d72fd0 Mon Sep 17 00:00:00 2001 From: "Ben Sheldon [he/him]" Date: Mon, 24 Apr 2023 08:09:05 -0700 Subject: [PATCH] Fix `GoodJob.cleanup_preserved_jobs` to add missing guard for unmigrated discrete executions (#938) --- lib/good_job.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/good_job.rb b/lib/good_job.rb index 85f034e91..57b019f7c 100644 --- a/lib/good_job.rb +++ b/lib/good_job.rb @@ -178,8 +178,10 @@ def self.cleanup_preserved_jobs(older_than: nil, in_batches_of: 1_000) active_job_ids = jobs_query.pluck(:active_job_id) break if active_job_ids.empty? - deleted_discrete_executions = GoodJob::DiscreteExecution.where(active_job_id: active_job_ids).delete_all - deleted_discrete_executions_count += deleted_discrete_executions + if GoodJob::Execution.discrete_support? + deleted_discrete_executions = GoodJob::DiscreteExecution.where(active_job_id: active_job_ids).delete_all + deleted_discrete_executions_count += deleted_discrete_executions + end deleted_executions = GoodJob::Execution.where(active_job_id: active_job_ids).delete_all deleted_executions_count += deleted_executions