Skip to content

Commit

Permalink
Fix conditional index migration to be rollbackable (#1176)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon authored Dec 12, 2023
1 parent 8c9a09d commit abd869d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration<%= mig

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], where: "(cron_key IS NOT NULL)",
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], where: "(cron_key IS NOT NULL)", unique: true,
add_index :good_jobs, [:cron_key, :cron_at], unique: true,
name: :index_good_jobs_on_cron_key_and_cron_at, algorithm: :concurrently
end

Expand Down

0 comments on commit abd869d

Please sign in to comment.