good_job 1.99.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
- class AddActiveJobIdIndexAndConcurrencyKeyIndexToGoodJobs < ActiveRecord::Migration[5.2]
3
- disable_ddl_transaction!
4
-
5
- UPDATE_BATCH_SIZE = 1_000
6
-
7
- class GoodJobJobs < ActiveRecord::Base
8
- self.table_name = "good_jobs"
9
- end
10
-
11
- def change
12
- reversible do |dir|
13
- dir.up do
14
- # Ensure this incremental update migration is idempotent
15
- # with monolithic install migration.
16
- return if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id_and_created_at)
17
- end
18
- end
19
-
20
- add_index :good_jobs, [:active_job_id, :created_at], algorithm: :concurrently, name: :index_good_jobs_on_active_job_id_and_created_at
21
- add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", algorithm: :concurrently, name: :index_good_jobs_on_concurrency_key_when_unfinished
22
- add_index :good_jobs, [:cron_key, :created_at], algorithm: :concurrently, name: :index_good_jobs_on_cron_key_and_created_at
23
-
24
- return unless defined? GoodJob::Job
25
-
26
- reversible do |dir|
27
- dir.up do
28
- # Ensure that all `good_jobs` records have an active_job_id value
29
- start_time = Time.current
30
- loop do
31
- 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?
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
- class AddRetriedGoodJobIdToGoodJobs < ActiveRecord::Migration[5.2]
3
- def change
4
- reversible do |dir|
5
- dir.up do
6
- # Ensure this incremental update migration is idempotent
7
- # with monolithic install migration.
8
- return if connection.column_exists?(:good_jobs, :retried_good_job_id)
9
- end
10
- end
11
-
12
- add_column :good_jobs, :retried_good_job_id, :uuid
13
- end
14
- end