Module: SchemaPlus::Indexes::RemoveIfExists

Instance Method Summary collapse

Instance Method Details

#remove_index(table_name, *args) ⇒ Object

Extends rails’ remove_index to include this options:

:if_exists


5
6
7
8
9
10
11
# File 'lib/schema_plus/indexes/remove_if_exists.rb', line 5

def remove_index(table_name, *args)
  options = args.extract_options!
  if_exists = options.delete(:if_exists)
  args << options if options.any?
  return if if_exists && !index_name_exists?(table_name, options[:name] || index_name(table_name, *args), false)
  super table_name, *args
end