Skip to content

Commit 447438f

Browse files
committed
Apply new good job migrations
By running `bin/rails g good_job:update` This isn't required, but is suggested in the good job readme and may improve performance.
1 parent 4f8af79 commit 447438f

5 files changed

Lines changed: 72 additions & 2 deletions
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.2]
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.2]
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.2]
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.2]
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: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)