Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Avoid rescue by checking for the table`s existence

ulferts57e67b2fb1e3
diff --git a/config/initializers/retry_failed_jobs_with_name_error.rb b/config/initializers/retry_failed_jobs_with_name_error.rb
index d8ce5849ccc..0efa810509a 100644
--- a/config/initializers/retry_failed_jobs_with_name_error.rb
+++ b/config/initializers/retry_failed_jobs_with_name_error.rb
@@ -38,6 +38,8 @@ Rails.application.configure do
#
# Once the migration is over and the worker gets restarted, the job will be
# retried thanks to this piece of code below.
+ next unless ActiveRecord::Base.connection.table_exists?(:good_jobs)
+
GoodJob::Job
.discarded
.where("error LIKE ?", "NameError: uninitialized constant %Job")
@@ -47,8 +49,6 @@ Rails.application.configure do
rescue StandardError => e
Rails.logger.error("Failed to enqueue job for retry #{job.display_name} (job id: #{job.id}): #{e.message}")
end
- rescue ActiveRecord::StatementInvalid
- # will happen when we currently are migrating
rescue LoadError
# Ignore LoadError that happens when nulldb://db database adapter is used
end