This repository has been archived on 2024-07-31 . You can view files and clone it, but cannot push or open issues or pull requests.
2018-05-14 13:56:17 -04:00
# frozen_string_literal: true
class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord :: Migration [ 5 . 1 ]
disable_ddl_transaction!
def change
safety_assured do
2018-07-15 08:56:00 -04: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 13:56:17 -04:00
end
2018-06-21 17:07:40 -04: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)' )
remove_index :statuses , column : [ :account_id , :id ] , where : 'visibility = 3' , algorithm : :concurrently if index_exists? ( :statuses , [ " account_id " , " id " ] , where : " (visibility = 3) " )
2018-05-14 13:56:17 -04:00
end
end