forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #CORE-1447 Change-Id: I92a2ca98b16aedec3a956d18287a82f0b6ccf1aa Reviewed-on: https://gerrit.instructure.com/152192 Tested-by: Jenkins Reviewed-by: Cody Cutrer <[email protected]> Product-Review: James Williams <[email protected]> QA-Review: James Williams <[email protected]>
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
db/migrate/20180601153421_replace_user_search_indexes_with_gin.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Copyright (C) 2014 - present Instructure, Inc. | ||
# | ||
# This file is part of Canvas. | ||
# | ||
# Canvas is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Affero General Public License as published by the Free | ||
# Software Foundation, version 3 of the License. | ||
# | ||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
class ReplaceUserSearchIndexesWithGin < ActiveRecord::Migration[5.1] | ||
tag :postdeploy | ||
disable_ddl_transaction! | ||
|
||
def up | ||
if (schema = connection.extension_installed?(:pg_trgm)) | ||
add_index :users, "lower(name) #{schema}.gin_trgm_ops", name: "index_gin_trgm_users_name", using: :gin, algorithm: :concurrently | ||
add_index :pseudonyms, "lower(sis_user_id) #{schema}.gin_trgm_ops", name: "index_gin_trgm_pseudonyms_sis_user_id", using: :gin, algorithm: :concurrently | ||
add_index :communication_channels, "lower(path) #{schema}.gin_trgm_ops", name: "index_gin_trgm_communication_channels_path", using: :gin, algorithm: :concurrently | ||
add_index :pseudonyms, "lower(unique_id) #{schema}.gin_trgm_ops", name: "index_gin_trgm_pseudonyms_unique_id", using: :gin, algorithm: :concurrently | ||
|
||
remove_index :users, name: "index_trgm_users_name" | ||
remove_index :pseudonyms, name: "index_trgm_pseudonyms_sis_user_id" | ||
remove_index :communication_channels, name: "index_trgm_communication_channels_path" | ||
remove_index :pseudonyms, name: "index_trgm_pseudonyms_unique_id" | ||
end | ||
end | ||
|
||
def down | ||
if (schema = connection.extension_installed?(:pg_trgm)) | ||
add_index :users, "lower(name) #{schema}.gist_trgm_ops", name: "index_trgm_users_name", using: :gist, algorithm: :concurrently | ||
add_index :pseudonyms, "lower(sis_user_id) #{schema}.gist_trgm_ops", name: "index_trgm_pseudonyms_sis_user_id", using: :gist, algorithm: :concurrently | ||
add_index :communication_channels, "lower(path) #{schema}.gist_trgm_ops", name: "index_trgm_communication_channels_path", using: :gist, algorithm: :concurrently | ||
add_index :pseudonyms, "lower(unique_id) #{schema}.gist_trgm_ops", name: "index_trgm_pseudonyms_unique_id", using: :gist, algorithm: :concurrently | ||
|
||
remove_index :users, name: "index_gin_trgm_users_name" | ||
remove_index :pseudonyms, name: "index_gin_trgm_pseudonyms_sis_user_id" | ||
remove_index :communication_channels, name: "index_gin_trgm_communication_channels_path" | ||
remove_index :pseudonyms, name: "index_gin_trgm_pseudonyms_unique_id" | ||
end | ||
end | ||
end |