-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename migration back to default good_job name, used for migration detection * bin/rails g good_job:update - Temporarily added a symlink from db/migrate => db/worker_jobs_migrate to work around bensheldon/good_job#352 * Patch GoodJob migration to use correct base class
- Loading branch information
1 parent
ac88f62
commit dc13a13
Showing
7 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
...er_jobs_migrate/20210826192727_add_active_job_id_concurrency_key_cron_key_to_good_jobs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
class AddActiveJobIdConcurrencyKeyCronKeyToGoodJobs < ActiveRecord::Migration[5.2] | ||
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, :active_job_id) | ||
end | ||
end | ||
|
||
add_column :good_jobs, :active_job_id, :uuid | ||
add_column :good_jobs, :concurrency_key, :text | ||
add_column :good_jobs, :cron_key, :text | ||
end | ||
end |
33 changes: 33 additions & 0 deletions
33
..._migrate/20210826192728_add_active_job_id_index_and_concurrency_key_index_to_good_jobs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
class AddActiveJobIdIndexAndConcurrencyKeyIndexToGoodJobs < ActiveRecord::Migration[5.2] | ||
disable_ddl_transaction! | ||
|
||
UPDATE_BATCH_SIZE = 1_000 | ||
|
||
class GoodJobJobs < WorkerJobApplicationRecord | ||
self.table_name = "good_jobs" | ||
end | ||
|
||
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_active_job_id_and_created_at) | ||
end | ||
end | ||
|
||
add_index :good_jobs, [:active_job_id, :created_at], algorithm: :concurrently, name: :index_good_jobs_on_active_job_id_and_created_at | ||
add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", algorithm: :concurrently, name: :index_good_jobs_on_concurrency_key_when_unfinished | ||
add_index :good_jobs, [:cron_key, :created_at], algorithm: :concurrently, name: :index_good_jobs_on_cron_key_and_created_at | ||
|
||
reversible do |dir| | ||
dir.up do | ||
start_time = Time.current | ||
loop do | ||
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 | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
db/worker_jobs_migrate/20210826192729_add_retried_good_job_id_to_good_jobs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
class AddRetriedGoodJobIdToGoodJobs < ActiveRecord::Migration[5.2] | ||
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, :retried_good_job_id) | ||
end | ||
end | ||
|
||
add_column :good_jobs, :retried_good_job_id, :uuid | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters