Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added option to name your index

  • Loading branch information...
commit 6ef03af22fc65e67cf4aa5cd959f8a167ffa08f1 1 parent 9d97475
@datwright authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/lhm/migrator.rb
View
9 lib/lhm/migrator.rb
@@ -95,8 +95,8 @@ def remove_column(name)
# @param [String, Symbol, Array<String, Symbol>] columns
# A column name given as String or Symbol. An Array of Strings or Symbols
# for compound indexes. It's possible to pass a length limit.
- def add_index(columns)
- ddl(index_ddl(columns))
+ def add_index(columns, options={})
+ ddl(index_ddl(columns, nil, options))
end
# Add a unique index to a table
@@ -167,9 +167,10 @@ def destination_read
Table.parse(@origin.destination_name, connection)
end
- def index_ddl(cols, unique = nil)
+ def index_ddl(cols, unique = nil, options)
type = unique ? "unique index" : "index"
- parts = [type, idx_name(@origin.name, cols), @name, idx_spec(cols)]
+ index_name = options[:name] || idx_name(@origin.name, cols)
+ parts = [type, index_name, @name, idx_spec(cols)]
"create %s `%s` on `%s` (%s)" % parts
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.