-
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.
These adjust indexes and add a column. As far as I can tell they don't affect the functionality of anything other than the dashboard.
- Loading branch information
root
committed
Mar 13, 2024
1 parent
2a9c885
commit de27194
Showing
6 changed files
with
128 additions
and
4 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
db/migrate/20240313144611_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.1] | ||
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 |
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobLabels < ActiveRecord::Migration[7.1] | ||
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, :labels) | ||
end | ||
end | ||
|
||
add_column :good_jobs, :labels, :text, array: true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobLabelsIndex < ActiveRecord::Migration[7.1] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels) | ||
add_index :good_jobs, :labels, using: :gin, where: "(labels IS NOT NULL)", | ||
name: :index_good_jobs_on_labels, algorithm: :concurrently | ||
end | ||
end | ||
|
||
dir.down do | ||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels) | ||
remove_index :good_jobs, name: :index_good_jobs_on_labels | ||
end | ||
end | ||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
db/migrate/20240313144614_remove_good_job_active_id_index.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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class RemoveGoodJobActiveIdIndex < ActiveRecord::Migration[7.1] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id) | ||
remove_index :good_jobs, name: :index_good_jobs_on_active_job_id | ||
end | ||
end | ||
|
||
dir.down do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id) | ||
add_index :good_jobs, :active_job_id, name: :index_good_jobs_on_active_job_id | ||
end | ||
end | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
db/migrate/20240313144615_create_index_good_job_jobs_for_candidate_lookup.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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateIndexGoodJobJobsForCandidateLookup < 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. | ||
return if connection.index_name_exists?(:good_jobs, :index_good_job_jobs_for_candidate_lookup) | ||
end | ||
end | ||
|
||
add_index :good_jobs, [:priority, :created_at], order: { priority: "ASC NULLS LAST", created_at: :asc }, | ||
where: "finished_at IS NULL", name: :index_good_job_jobs_for_candidate_lookup, | ||
algorithm: :concurrently | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.