From f180880f657c92b5deec181486c4ebd3a0aa4f79 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 7 Nov 2024 10:40:41 -0500 Subject: [PATCH] Remove postgres version support check for `REINDEX` in migration (#32744) --- ...51_add_unique_index_on_preview_cards_statuses.rb | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb b/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb index 4271f8c08a..c35ad80028 100644 --- a/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb +++ b/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb @@ -15,21 +15,10 @@ class AddUniqueIndexOnPreviewCardsStatuses < ActiveRecord::Migration[6.1] private - def supports_concurrent_reindex? - @supports_concurrent_reindex ||= begin - ActiveRecord::Base.connection.database_version >= 120_000 - end - end - def deduplicate_and_reindex! deduplicate_preview_cards! - if supports_concurrent_reindex? - safety_assured { execute 'REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey' } - else - remove_index :preview_cards_statuses, name: :preview_cards_statuses_pkey - add_index :preview_cards_statuses, [:status_id, :preview_card_id], name: :preview_cards_statuses_pkey, algorithm: :concurrently, unique: true - end + safety_assured { execute 'REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey' } rescue ActiveRecord::RecordNotUnique retry end