2018-05-14 17:56:17 +00:00
# frozen_string_literal: true
2023-03-27 14:09:10 +00:00
class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord :: Migration [ 5 . 2 ]
2018-05-14 17:56:17 +00:00
disable_ddl_transaction!
def change
safety_assured do
2023-02-18 22:38:14 +00:00
add_index :statuses , [ :account_id , :id , :visibility , :updated_at ] , order : { id : :desc } , algorithm : :concurrently , name : :index_statuses_20180106 unless index_name_exists? ( :statuses , 'index_statuses_20180106' )
2018-05-14 17:56:17 +00:00
end
2018-06-21 21:07:40 +00:00
# These index may not exists (see migration 20180514130000)
remove_index :statuses , column : [ :account_id , :id , :visibility ] , where : 'visibility IN (0, 1, 2)' , algorithm : :concurrently if index_exists? ( :statuses , [ :account_id , :id , :visibility ] , where : 'visibility IN (0, 1, 2)' )
2023-02-20 05:14:10 +00:00
remove_index :statuses , column : [ :account_id , :id ] , where : 'visibility = 3' , algorithm : :concurrently if index_exists? ( :statuses , %w( account_id id ) , where : '(visibility = 3)' )
2018-05-14 17:56:17 +00:00
end
end