add more gist indexes

closes CNVS-5180

Change-Id: Ib9d0db2d03c9c24f9536202e41cbeca4c2cd6b65
Reviewed-on: https://gerrit.instructure.com/26038
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:
Cody Cutrer 2013-11-06 10:15:51 -07:00
parent ec58fb4b4f
commit d4343d7f74
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
class AddMoreGistIndexes < ActiveRecord::Migration
disable_ddl_transaction!
tag :predeploy
def self.up
if is_postgres? && has_postgres_proc?('show_trgm')
concurrently = " CONCURRENTLY" if connection.open_transactions == 0
execute("CREATE INDEX#{concurrently} index_trgm_users_short_name ON users USING gist(LOWER(short_name) gist_trgm_ops)")
execute("CREATE INDEX#{concurrently} index_trgm_courses_name ON courses USING gist(LOWER(name) gist_trgm_ops)")
execute("CREATE INDEX#{concurrently} index_trgm_courses_course_code ON courses USING gist(LOWER(course_code) gist_trgm_ops)")
execute("CREATE INDEX#{concurrently} index_trgm_courses_sis_source_id ON courses USING gist(LOWER(sis_source_id) gist_trgm_ops)")
end
end
def self.down
remove_index :users, name: 'index_trgm_users_short_name'
remove_index :courses, name: 'index_trgm_courses_name'
remove_index :courses, name: 'index_trgm_courses_course_code'
remove_index :courses, name: 'index_trgm_courses_sis_source_id'
end
end