From e19f517a80ad85850b6578131bc8219a561ece5e Mon Sep 17 00:00:00 2001 From: Zach Margolis Date: Tue, 23 Nov 2021 12:17:06 -0800 Subject: [PATCH] Upgrade good_job gem to 2.7 - Ran `bin/rails g good_job:update --database worker_jobs` --- Gemfile | 2 +- Gemfile.lock | 8 +++++--- ...20211123201553_add_cron_at_to_good_jobs.rb | 14 +++++++++++++ ...add_cron_key_cron_at_index_to_good_jobs.rb | 20 +++++++++++++++++++ db/worker_jobs_schema.rb | 4 +++- 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 db/worker_jobs_migrate/20211123201553_add_cron_at_to_good_jobs.rb create mode 100644 db/worker_jobs_migrate/20211123201554_add_cron_key_cron_at_index_to_good_jobs.rb diff --git a/Gemfile b/Gemfile index e18d691d5e5..d6b36601f4c 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ gem 'devise', '~> 4.8' gem 'dotiw', '>= 4.0.1' gem 'faraday' gem 'foundation_emails' -gem 'good_job', '~> 2.2.0' +gem 'good_job', '~> 2.7.0' gem 'hashie', '~> 4.1' gem 'hiredis', '~> 0.6.0' gem 'http_accept_language' diff --git a/Gemfile.lock b/Gemfile.lock index eac0f8942a4..2dbb19691c8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -260,7 +260,7 @@ GEM smart_properties errbase (0.2.0) erubi (1.10.0) - et-orbi (1.2.5) + et-orbi (1.2.6) tzinfo execjs (2.8.1) factory_bot (6.2.0) @@ -287,13 +287,14 @@ GEM ffi (~> 1.0) globalid (0.5.2) activesupport (>= 5.0) - good_job (2.2.0) + good_job (2.7.0) activejob (>= 5.2.0) activerecord (>= 5.2.0) concurrent-ruby (>= 1.0.2) fugit (>= 1.1) railties (>= 5.2.0) thor (>= 0.14.1) + webrick (>= 1.3) zeitwerk (>= 2.0) guard (2.16.2) formatador (>= 0.2.4) @@ -660,6 +661,7 @@ GEM rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) + webrick (1.7.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -712,7 +714,7 @@ DEPENDENCIES faker faraday foundation_emails - good_job (~> 2.2.0) + good_job (~> 2.7.0) guard-rspec hashie (~> 4.1) hiredis (~> 0.6.0) diff --git a/db/worker_jobs_migrate/20211123201553_add_cron_at_to_good_jobs.rb b/db/worker_jobs_migrate/20211123201553_add_cron_at_to_good_jobs.rb new file mode 100644 index 00000000000..e7c7a370287 --- /dev/null +++ b/db/worker_jobs_migrate/20211123201553_add_cron_at_to_good_jobs.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true +class AddCronAtToGoodJobs < ActiveRecord::Migration[6.1] + def change + reversible do |dir| + dir.up do + # Ensure this incremental update migration is idempotent + # with monolithic install migration. + return if connection.column_exists?(:good_jobs, :cron_at) + end + end + + add_column :good_jobs, :cron_at, :timestamp + end +end diff --git a/db/worker_jobs_migrate/20211123201554_add_cron_key_cron_at_index_to_good_jobs.rb b/db/worker_jobs_migrate/20211123201554_add_cron_key_cron_at_index_to_good_jobs.rb new file mode 100644 index 00000000000..5a0991371cc --- /dev/null +++ b/db/worker_jobs_migrate/20211123201554_add_cron_key_cron_at_index_to_good_jobs.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true +class AddCronKeyCronAtIndexToGoodJobs < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + + def change + reversible do |dir| + dir.up do + # Ensure this incremental update migration is idempotent + # with monolithic install migration. + return if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at) + end + end + + add_index :good_jobs, + [:cron_key, :cron_at], + algorithm: :concurrently, + name: :index_good_jobs_on_cron_key_and_cron_at, + unique: true + end +end diff --git a/db/worker_jobs_schema.rb b/db/worker_jobs_schema.rb index a9781f1cf35..a7135e11443 100644 --- a/db/worker_jobs_schema.rb +++ b/db/worker_jobs_schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_26_192729) do +ActiveRecord::Schema.define(version: 2021_11_23_201554) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -30,9 +30,11 @@ t.text "concurrency_key" t.text "cron_key" t.uuid "retried_good_job_id" + t.datetime "cron_at" t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at" t.index ["concurrency_key"], name: "index_good_jobs_on_concurrency_key_when_unfinished", where: "(finished_at IS NULL)" t.index ["cron_key", "created_at"], name: "index_good_jobs_on_cron_key_and_created_at" + t.index ["cron_key", "cron_at"], name: "index_good_jobs_on_cron_key_and_cron_at", unique: true t.index ["queue_name", "scheduled_at"], name: "index_good_jobs_on_queue_name_and_scheduled_at", where: "(finished_at IS NULL)" t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)" end