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