lib/lhm/migrator.rb
def remove_index(columns, index_name = nil)
      columns = [columns].flatten.map(&:to_sym)
      from_origin = @origin.indices.find {|name, cols| cols.map(&:to_sym) == columns}
      index_name ||= from_origin[0] unless from_origin.nil?
      index_name ||= idx_name(@origin.name, columns)
      ddl("drop index `%s` on `%s`" % [index_name, @name])
    end
# Remove an index from a table
#
# @example
#
#   Lhm.change_table(:users) do |m|
#     m.remove_index(:comment)
#     m.remove_index([:username, :created_at])
#   end
#
# @param [String, Symbol, Array<String, Symbol>] columns
#   A column name given as String or Symbol. An Array of Strings or Symbols
#   for compound indexes.
# @param [String, Symbol] index_name
#   Optional name of the index to be removed
Remove an index from a table
Remove an index from a table
def remove_index(columns, index_name = nil)
      columns = [columns].flatten.map(&:to_sym)
      from_origin = @origin.indices.find {|name, cols| cols.map(&:to_sym) == columns}
      index_name ||= from_origin[0] unless from_origin.nil?
      index_name ||= idx_name(@origin.name, columns)
      ddl("drop index `%s` on `%s`" % [index_name, @name])
    end
def remove_index ( columns , index_name = nil ) columns = [ columns ] . flatten . map ( & :to_sym ) from_origin = @origin . indices . find { | name , cols | cols . map ( & :to_sym ) == columns } index_name ||= from_origin [ 0 ] unless from_origin . nil? index_name ||= idx_name ( @origin . name , columns ) ddl ( "drop index `%s` on `%s`" % [ index_name , @name ] ) end
Remove an index from a table
Remove an index from a table
columns
index_name
index_name Optional name of the index to be removed
index_name Optional name of the index to be removed
example
None