Skip to content

Commit

Permalink
Fix column index config
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmetal committed Nov 21, 2017
1 parent 02fb7a2 commit 933fb9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/uuidable/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ module Uuidable
# Module adds method to table definition
module TableDefinition
def uuid(opts = {})
index_opts = opts.delete(:index) || {}
index_opts = opts.delete(:index)
index_opts = {} if index_opts.nil?

column_name = opts.delete(:column_name) || COLUMN_NAME

column column_name, COLUMN_TYPE, COLUMN_OPTIONS.merge(opts)
index column_name, INDEX_OPTIONS.merge(index_opts) unless index_opts == false
index column_name, INDEX_OPTIONS.merge(index_opts) if index_opts
end
end

Expand All @@ -25,7 +27,7 @@ def add_uuid_column(table_name, opts = {})

add_column table_name, column_name, COLUMN_TYPE, COLUMN_OPTIONS.merge(opts)

add_uuid_index(table_name, index_opts.merge(column_name: column_name)) unless index_opts.nil?
add_uuid_index(table_name, index_opts.merge(column_name: column_name)) if index_opts
end

def add_uuid_index(table_name, opts = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/uuidable/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Uuidable
VERSION = '0.2.1'.freeze
VERSION = '0.2.2'.freeze
end

0 comments on commit 933fb9e

Please sign in to comment.