fix attachments sorting indexes
refs CNVS-5180 Change-Id: Idb1e0e75c71953d365a7faa54d6eea332c6bc5c9 Reviewed-on: https://gerrit.instructure.com/26029 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
2581cce3c3
commit
d2db6ead45
|
@ -15,11 +15,11 @@ class AddAttachmentIndexesForSorting < ActiveRecord::Migration
|
|||
end
|
||||
add_index :attachments, [:folder_id, :file_state, :position], :algorithm => :concurrently
|
||||
|
||||
remove_index :attachments, "index_attachments_on_folder_id"
|
||||
remove_index :attachments, :folder_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
add_index :attachments, [:folder_id], :name => "index_attachments_on_folder_id"
|
||||
add_index :attachments, :folder_id, algorithm: :concurrently
|
||||
remove_index :attachments, "index_attachments_on_folder_id_and_file_state_and_display_name"
|
||||
remove_index :attachments, "index_attachments_on_folder_id_and_file_state_and_position"
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class FixAttachmentSortingIndexes < ActiveRecord::Migration
|
||||
tag :postdeploy
|
||||
disable_ddl_transaction!
|
||||
|
||||
def self.up
|
||||
if connection.adapter_name == 'PostgreSQL' && connection.select_value("SELECT 1 FROM pg_index WHERE indexrelid='index_attachments_on_folder_id_and_file_state_and_position'::regclass AND indpred IS NOT NULL")
|
||||
execute("ALTER INDEX index_attachments_on_folder_id_and_file_state_and_position RENAME TO index_attachments_on_folder_id_and_file_state_and_position2")
|
||||
add_index :attachments, [:folder_id, :file_state, :position], :algorithm => :concurrently
|
||||
remove_index :attachments, name: 'index_attachments_on_folder_id_and_file_state_and_position2'
|
||||
end
|
||||
remove_index :attachments, :folder_id
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue