more fk indexes

also fix an old migration that should have ran on all shards

Change-Id: Ib4305c4f1b84ba0cfd525d0f552cfc21d365dc24
Reviewed-on: https://gerrit.instructure.com/37492
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@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:
Cody Cutrer 2014-07-10 10:24:23 -06:00
parent 4872ee008e
commit 9b1e8c7350
2 changed files with 14 additions and 2 deletions

View File

@ -2,14 +2,12 @@ class AddUniqueIndexOnNotifications < ActiveRecord::Migration
tag :postdeploy
def self.up
return unless Shard.current.default?
# the excess subquery is necessary to avoid error 1093 on mysql
Notification.where("id NOT IN (SELECT * FROM (SELECT MIN(id) FROM notifications GROUP BY name) x)").delete_all
add_index :notifications, [:name], :unique => true, :name => "index_notifications_unique_on_name"
end
def self.down
return unless Shard.current.default?
remove_index :notifications, :name => "index_notifications_unique_on_name"
end
end

View File

@ -0,0 +1,14 @@
class AddForeignKeyIndexes3 < ActiveRecord::Migration
tag :postdeploy
disable_ddl_transaction!
def self.up
add_index :account_reports, :attachment_id, algorithm: :concurrently
add_index :zip_file_imports, :attachment_id, algorithm: :concurrently
end
def self.down
remove_index :account_reports, :attachment_id
remove_index :zip_file_imports, :attachment_id
end
end