-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
demo/db/migrate/20231128075428_recreate_good_job_cron_indexes.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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class RecreateGoodJobCronIndexes < ActiveRecord::Migration[7.1] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
remove_index :good_jobs, [:cron_key, :created_at] if index_exists?(:good_jobs, [:cron_key, :created_at]) | ||
remove_index :good_jobs, [:cron_key, :cron_at] if index_exists?(:good_jobs, [:cron_key, :cron_at]) | ||
|
||
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)", | ||
name: :index_good_jobs_on_cron_key_and_created_at, algorithm: :concurrently | ||
|
||
add_index :good_jobs, [:cron_key, :cron_at], where: "(cron_key IS NOT NULL)", unique: true, | ||
name: :index_good_jobs_on_cron_key_and_cron_at, algorithm: :concurrently | ||
end | ||
end | ||
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
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
22 changes: 22 additions & 0 deletions
22
lib/generators/good_job/templates/update/migrations/07_recreate_good_job_cron_indexes.rb.erb
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class RecreateGoodJobCronIndexes < ActiveRecord::Migration<%= migration_version %> | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
remove_index :good_jobs, [:cron_key, :created_at] if index_exists?(:good_jobs, [:cron_key, :created_at]) | ||
remove_index :good_jobs, [:cron_key, :cron_at] if index_exists?(:good_jobs, [:cron_key, :cron_at]) | ||
|
||
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)", | ||
name: :index_good_jobs_on_cron_key_and_created_at, algorithm: :concurrently | ||
|
||
add_index :good_jobs, [:cron_key, :cron_at], where: "(cron_key IS NOT NULL)", unique: true, | ||
name: :index_good_jobs_on_cron_key_and_cron_at, algorithm: :concurrently | ||
end | ||
end | ||
end | ||
end |