2018-05-14 12:56:17 -05:00
# frozen_string_literal: true
2023-03-27 09:09:10 -05:00
class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord :: Migration [ 5 . 2 ]
2018-05-14 12:56:17 -05:00
disable_ddl_transaction!
def change
safety_assured do
2023-02-18 16:38:14 -06: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 12:56:17 -05:00
end
2018-06-21 16:07:40 -05: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-19 23:14:10 -06: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 12:56:17 -05:00
end
end