lib/ridgepole/diff.rb in ridgepole-0.4.2 vs lib/ridgepole/diff.rb in ridgepole-0.4.3
- old
+ new
@@ -175,11 +175,25 @@
from = (from || {}).dup
to = (to || {}).dup
indices_delta = {}
to.each do |index_name, to_attrs|
- if (from_attrs = from.delete(index_name))
+ if index_name.kind_of?(Array)
+ from_index_name, from_attrs = from.find {|name, attrs| attrs[:column_name] == index_name }
+
+ if from_attrs
+ from.delete(from_index_name)
+ from_attrs[:options].delete(:name)
+ end
+ else
+ from_attrs = from.delete(index_name)
+ end
+
+ if from_attrs
+ normalize_index_options!(from_attrs[:options])
+ normalize_index_options!(to_attrs[:options])
+
if from_attrs != to_attrs
indices_delta[:add] ||= {}
indices_delta[:add][index_name] = to_attrs
unless @options[:merge]
@@ -220,10 +234,16 @@
end
def normalize_column_options!(opts)
opts[:null] = true unless opts.has_key?(:null)
+ # XXX: MySQL only?
unless @options[:disable_mysql_unsigned]
opts[:unsigned] = false unless opts.has_key?(:unsigned)
end
+ end
+
+ def normalize_index_options!(opts)
+ # XXX: MySQL only?
+ opts[:using] = :btree unless opts.has_key?(:using)
end
end