2013-07-09 05:07:57 +08:00
class OptimizeScribdRecyclableIndex < ActiveRecord :: Migration
tag :postdeploy
2013-10-26 06:12:54 +08:00
disable_ddl_transaction!
2013-07-09 05:07:57 +08:00
def self . up
if connection . adapter_name == 'PostgreSQL'
remove_index :attachments , name : 'scribd_attempts_smt_workflow_state'
2013-10-30 05:11:19 +08:00
add_index :attachments , :scribd_attempts , algorithm : :concurrently , where : " workflow_state='errored' AND scribd_mime_type_id IS NOT NULL " , name : 'scribd_attempts_smt_workflow_state'
2013-07-09 05:07:57 +08:00
end
end
def self . down
if connection . adapter_name == 'PostgreSQL'
remove_index :attachments , name : 'scribd_attempts_smt_workflow_state'
2013-10-26 06:06:28 +08:00
add_index :attachments , [ :scribd_attempts , :scribd_mime_type_id , :workflow_state ] , algorithm : :concurrently , name : 'scribd_attempts_smt_workflow_state'
2013-07-09 05:07:57 +08:00
end
end
end