Skip to content

Commit

Permalink
Fix v1.99 migration to use migration-specific job class
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Jul 18, 2024
1 parent 396fd96 commit 5bcf328
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.2
2.7.8
9 changes: 4 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ GEM
rake (>= 10.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
html_tokenizer (0.0.7)
html_tokenizer (0.0.8)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jdbc-postgres (42.2.14)
Expand Down Expand Up @@ -225,12 +225,11 @@ GEM
tomlrb
mixlib-shellout (3.2.5)
chef-utils
msgpack (1.4.2)
msgpack (1.4.2-java)
msgpack (1.7.2)
multi_json (1.15.0)
multipart-post (2.1.1)
nio4r (2.5.7)
nio4r (2.5.7-java)
nio4r (2.7.3)
nio4r (2.7.3-java)
nokogiri (1.11.7)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class AddActiveJobIdIndexAndConcurrencyKeyIndexToGoodJobs < ActiveRecord::Migrat

UPDATE_BATCH_SIZE = 1_000

class GoodJobJobs < ActiveRecord::Base
self.table_name = "good_jobs"
end

def change
reversible do |dir|
dir.up do
Expand All @@ -24,7 +28,7 @@ def change
# Ensure that all `good_jobs` records have an active_job_id value
start_time = Time.current
loop do
break if GoodJob::Job.where(active_job_id: nil, finished_at: nil).where("created_at < ?", start_time).limit(UPDATE_BATCH_SIZE).update_all("active_job_id = (serialized_params->>'job_id')::uuid").zero?
break if GoodJobJobs.where(active_job_id: nil, finished_at: nil).where("created_at < ?", start_time).limit(UPDATE_BATCH_SIZE).update_all("active_job_id = (serialized_params->>'job_id')::uuid").zero?
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class AddActiveJobIdIndexAndConcurrencyKeyIndexToGoodJobs < ActiveRecord::Migrat

UPDATE_BATCH_SIZE = 1_000

class GoodJobJobs < ActiveRecord::Base
self.table_name = "good_jobs"
end

def change
reversible do |dir|
dir.up do
Expand All @@ -24,7 +28,7 @@ def change
# Ensure that all `good_jobs` records have an active_job_id value
start_time = Time.current
loop do
break if GoodJob::Job.where(active_job_id: nil, finished_at: nil).where("created_at < ?", start_time).limit(UPDATE_BATCH_SIZE).update_all("active_job_id = (serialized_params->>'job_id')::uuid").zero?
break if GoodJobJobs.where(active_job_id: nil, finished_at: nil).where("created_at < ?", start_time).limit(UPDATE_BATCH_SIZE).update_all("active_job_id = (serialized_params->>'job_id')::uuid").zero?
end
end
end
Expand Down

0 comments on commit 5bcf328

Please sign in to comment.