Skip to content

Commit

Permalink
Hotfix, do not create unique index by default when add column
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmetal committed Sep 5, 2017
1 parent 23fe1f0 commit 02fb7a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/uuidable/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Uuidable
# Module adds method to table definition
module TableDefinition
def uuid(opts = {})
index_opts = opts.delete(:index)
index_opts = opts.delete(:index) || {}
column_name = opts.delete(:column_name) || COLUMN_NAME

column column_name, COLUMN_TYPE, COLUMN_OPTIONS.merge(opts)
Expand All @@ -19,11 +19,13 @@ def uuid(opts = {})
module Migration
def add_uuid_column(table_name, opts = {})
index_opts = opts.delete(:index)
index_opts = {} if index_opts == true

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

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

add_uuid_index(index_opts.merge(column_name: column_name)) unless index_opts == false
add_uuid_index(table_name, index_opts.merge(column_name: column_name)) unless index_opts.nil?
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.0'.freeze
VERSION = '0.2.1'.freeze
end

0 comments on commit 02fb7a2

Please sign in to comment.