-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
bb55cf2
commit d38809b
Showing
22 changed files
with
265 additions
and
64 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
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
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
db/migrate/20240811043449_recreate_good_job_cron_indexes_with_conditional.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,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration[7.0] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond) | ||
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)", | ||
name: :index_good_jobs_on_cron_key_and_created_at_cond, algorithm: :concurrently | ||
end | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond) | ||
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_cond, algorithm: :concurrently | ||
end | ||
|
||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at) | ||
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at | ||
end | ||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at) | ||
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at | ||
end | ||
end | ||
|
||
dir.down do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at) | ||
add_index :good_jobs, [:cron_key, :created_at], | ||
name: :index_good_jobs_on_cron_key_and_created_at, algorithm: :concurrently | ||
end | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at) | ||
add_index :good_jobs, [:cron_key, :cron_at], unique: true, | ||
name: :index_good_jobs_on_cron_key_and_cron_at, algorithm: :concurrently | ||
end | ||
|
||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond) | ||
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at_cond | ||
end | ||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond) | ||
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at_cond | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.