lib/rom/sql/migration/schema_diff.rb in rom-sql-2.0.0.beta1 vs lib/rom/sql/migration/schema_diff.rb in rom-sql-2.0.0.beta2
- old
+ new
@@ -109,13 +109,33 @@
def initialize(index)
@index = index
end
- def attribute
- index.attributes[0].name
+ def attributes
+ index.attributes.map(&:name)
end
+
+ def name
+ index.name
+ end
+
+ def unique?
+ index.unique?
+ end
+
+ def type
+ index.type
+ end
+
+ def predicate
+ index.predicate
+ end
+
+ def partial?
+ !predicate.nil?
+ end
end
class IndexAdded < IndexDiff
end
@@ -163,10 +183,10 @@
def compare_indexes(current, target)
added_indexes = target.indexes.reject { |idx|
current.indexes.any? { |curr_idx| curr_idx.attributes == idx.attributes }
}
removed_indexes = current.indexes.select { |idx|
- target.indexes.none? { |tgt_idx| idx.attributes == tgt_idx }
+ target.indexes.none? { |tgt_idx| idx.attributes == tgt_idx.attributes }
}
removed_indexes.map { |idx| IndexRemoved.new(idx) } +
added_indexes.map { |idx| IndexAdded.new(idx) }
end