Skip to content

Commit 264813f

Browse files
committed
Gemfile: Update to Good Job 4.x
Production console shows that we are `v4_ready?`, so let's go for it. This includes additional database migrations for v4 features. Ref: AP-270
1 parent 1f2be1d commit 264813f

8 files changed

Lines changed: 99 additions & 11 deletions

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ gem 'berkeley_library-util', '~> 0.3'
1414
gem 'bootstrap'
1515
gem 'dotenv-rails', '~> 2.8.1', require: 'dotenv/rails-now'
1616
gem 'faraday'
17-
gem 'good_job', '~> 3.99'
17+
gem 'good_job', '~> 4.0'
1818
gem 'ipaddress'
1919
gem 'jaro_winkler', '~> 1.5.5'
2020
gem 'jquery-rails'

Gemfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ GEM
187187
raabro (~> 1.4)
188188
globalid (1.2.1)
189189
activesupport (>= 6.1)
190-
good_job (3.99.1)
191-
activejob (>= 6.0.0)
192-
activerecord (>= 6.0.0)
193-
concurrent-ruby (>= 1.0.2)
194-
fugit (>= 1.1)
195-
railties (>= 6.0.0)
196-
thor (>= 0.14.1)
190+
good_job (4.13.2)
191+
activejob (>= 6.1.0)
192+
activerecord (>= 6.1.0)
193+
concurrent-ruby (>= 1.3.1)
194+
fugit (>= 1.11.0)
195+
railties (>= 6.1.0)
196+
thor (>= 1.0.0)
197197
hashdiff (1.0.1)
198198
hashie (5.0.0)
199199
http-accept (1.7.0)
@@ -530,7 +530,7 @@ DEPENDENCIES
530530
database_cleaner-active_record (~> 2.1)
531531
dotenv-rails (~> 2.8.1)
532532
faraday
533-
good_job (~> 3.99)
533+
good_job (~> 4.0)
534534
ipaddress
535535
jaro_winkler (~> 1.5.5)
536536
jquery-rails
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class AddJobsFinishedAtToGoodJobBatches < ActiveRecord::Migration[7.1]
4+
def change
5+
reversible do |dir|
6+
dir.up do
7+
# Ensure this incremental update migration is idempotent
8+
# with monolithic install migration.
9+
return if connection.column_exists?(:good_job_batches, :jobs_finished_at)
10+
end
11+
end
12+
13+
change_table :good_job_batches do |t|
14+
t.datetime :jobs_finished_at
15+
end
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class AddIndexGoodJobsConcurrencyKeyCreatedAt < ActiveRecord::Migration[7.1]
4+
disable_ddl_transaction!
5+
6+
def change
7+
reversible do |dir|
8+
dir.up do
9+
# Ensure this incremental update migration is idempotent
10+
# with monolithic install migration.
11+
return if connection.index_exists? :good_jobs, [:concurrency_key, :created_at]
12+
end
13+
end
14+
15+
add_index :good_jobs, [:concurrency_key, :created_at], algorithm: :concurrently
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class AddIndexGoodJobsJobClass < ActiveRecord::Migration[7.1]
4+
disable_ddl_transaction!
5+
6+
def change
7+
reversible do |dir|
8+
dir.up do
9+
# Ensure this incremental update migration is idempotent
10+
# with monolithic install migration.
11+
return if connection.index_exists? :good_jobs, :job_class
12+
end
13+
end
14+
15+
add_index :good_jobs, :job_class, algorithm: :concurrently
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class AddIndexGoodJobsFinishedAtForCleanup < ActiveRecord::Migration[7.1]
4+
disable_ddl_transaction!
5+
6+
def change
7+
reversible do |dir|
8+
dir.up do
9+
# Ensure this incremental update migration is idempotent
10+
# with monolithic install migration.
11+
return if connection.index_exists? :good_jobs, [:finished_at], name: :index_good_jobs_jobs_on_finished_at_only
12+
end
13+
end
14+
15+
add_index :good_jobs, [:finished_at], where: "finished_at IS NOT NULL", name: :index_good_jobs_jobs_on_finished_at_only, algorithm: :concurrently
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class RemoveExtraneousFinishedAtIndex < ActiveRecord::Migration[7.1]
4+
disable_ddl_transaction!
5+
6+
def change
7+
reversible do |dir|
8+
dir.up do
9+
# Ensure this incremental update migration is idempotent
10+
# with monolithic install migration.
11+
return unless connection.index_exists? :good_jobs, [:finished_at], name: :index_good_jobs_jobs_on_finished_at
12+
end
13+
end
14+
15+
remove_index :good_jobs, [:finished_at], where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL", name: :index_good_jobs_jobs_on_finished_at, algorithm: :concurrently
16+
end
17+
end

db/schema.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.1].define(version: 2026_01_28_024814) do
13+
ActiveRecord::Schema[7.1].define(version: 2026_02_19_014106) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "pgcrypto"
1616
enable_extension "plpgsql"
@@ -72,6 +72,7 @@
7272
t.datetime "enqueued_at"
7373
t.datetime "discarded_at"
7474
t.datetime "finished_at"
75+
t.datetime "jobs_finished_at"
7576
end
7677

7778
create_table "good_job_executions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
@@ -134,10 +135,12 @@
134135
t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at"
135136
t.index ["batch_callback_id"], name: "index_good_jobs_on_batch_callback_id", where: "(batch_callback_id IS NOT NULL)"
136137
t.index ["batch_id"], name: "index_good_jobs_on_batch_id", where: "(batch_id IS NOT NULL)"
138+
t.index ["concurrency_key", "created_at"], name: "index_good_jobs_on_concurrency_key_and_created_at"
137139
t.index ["concurrency_key"], name: "index_good_jobs_on_concurrency_key_when_unfinished", where: "(finished_at IS NULL)"
138140
t.index ["cron_key", "created_at"], name: "index_good_jobs_on_cron_key_and_created_at_cond", where: "(cron_key IS NOT NULL)"
139141
t.index ["cron_key", "cron_at"], name: "index_good_jobs_on_cron_key_and_cron_at_cond", unique: true, where: "(cron_key IS NOT NULL)"
140-
t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at", where: "((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL))"
142+
t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at_only", where: "(finished_at IS NOT NULL)"
143+
t.index ["job_class"], name: "index_good_jobs_on_job_class"
141144
t.index ["labels"], name: "index_good_jobs_on_labels", where: "(labels IS NOT NULL)", using: :gin
142145
t.index ["locked_by_id"], name: "index_good_jobs_on_locked_by_id", where: "(locked_by_id IS NOT NULL)"
143146
t.index ["priority", "created_at"], name: "index_good_job_jobs_for_candidate_lookup", where: "(finished_at IS NULL)"

0 commit comments

Comments
 (0)