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:
parent
e53496af73
commit
46309f949d
|
@ -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
|
||||
|
|
|
@ -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')")
|
||||
|
|
Loading…
Reference in New Issue