use index_exists? the right way

fixes CNVS-30741

Change-Id: Iadbfc515264f4af598eed38baef84cacb5988e61
Reviewed-on: https://gerrit.instructure.com/86772
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Alex Boyd <aboyd@instructure.com>
QA-Review: Alex Boyd <aboyd@instructure.com>
This commit is contained in:
Alex Boyd 2016-08-03 02:00:47 -06:00
parent e53496af73
commit 46309f949d
2 changed files with 3 additions and 3 deletions

View File

@ -13,7 +13,7 @@ class AddUserActiveOnlyGistIndexes < ActiveRecord::Migration
end
def self.down
remove_index :users, name: 'index_trgm_users_name_active_only' if index_exists?(:users, 'index_trgm_users_name_active_only')
remove_index :users, name: 'index_trgm_users_name_active_only' if index_exists?(:users, :name, name: 'index_trgm_users_name_active_only')
remove_index :users, name: 'index_trgm_users_short_name_active_only'
end
end

View File

@ -4,7 +4,7 @@ class FixUserActiveOnlyGistIndexes < ActiveRecord::Migration
def self.up
if schema = connection.extension_installed?(:pg_trgm)
remove_index :users, name: 'index_trgm_users_name_active_only' if index_exists?(:users, 'index_trgm_users_name_active_only')
remove_index :users, name: 'index_trgm_users_name_active_only' if index_exists?(:users, :name, name: 'index_trgm_users_name_active_only')
concurrently = " CONCURRENTLY" if connection.open_transactions == 0
execute("CREATE INDEX#{concurrently} index_trgm_users_name_active_only ON #{User.quoted_table_name} USING gist(LOWER(name) #{schema}.gist_trgm_ops) WHERE workflow_state IN ('registered', 'pre_registered')")
@ -13,7 +13,7 @@ class FixUserActiveOnlyGistIndexes < ActiveRecord::Migration
def self.down
if schema = connection.extension_installed?(:pg_trgm)
remove_index :users, name: 'index_trgm_users_name_active_only' if index_exists?(:users, 'index_trgm_users_name_active_only')
remove_index :users, name: 'index_trgm_users_name_active_only' if index_exists?(:users, :name, name: 'index_trgm_users_name_active_only')
concurrently = " CONCURRENTLY" if connection.open_transactions == 0
execute("CREATE INDEX#{concurrently} index_trgm_users_name_active_only ON #{User.quoted_table_name} USING gist(LOWER(short_name) #{schema}.gist_trgm_ops) WHERE workflow_state IN ('registered', 'pre_registered')")