mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 07:21:51 +00:00
Remove postgres version support check for REINDEX
in migration (#32744)
This commit is contained in:
parent
870bb06994
commit
f180880f65
|
@ -15,21 +15,10 @@ class AddUniqueIndexOnPreviewCardsStatuses < ActiveRecord::Migration[6.1]
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def supports_concurrent_reindex?
|
|
||||||
@supports_concurrent_reindex ||= begin
|
|
||||||
ActiveRecord::Base.connection.database_version >= 120_000
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def deduplicate_and_reindex!
|
def deduplicate_and_reindex!
|
||||||
deduplicate_preview_cards!
|
deduplicate_preview_cards!
|
||||||
|
|
||||||
if supports_concurrent_reindex?
|
safety_assured { execute 'REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey' }
|
||||||
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
|
|
||||||
rescue ActiveRecord::RecordNotUnique
|
rescue ActiveRecord::RecordNotUnique
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user