lib/neo4j/migrations/helpers/schema.rb in activegraph-10.0.0.pre.alpha.6 vs lib/neo4j/migrations/helpers/schema.rb in activegraph-10.0.0.pre.alpha.7

- old
+ new

@@ -8,17 +8,29 @@ def add_constraint(label, property, options = {}) force = options[:force] || false type = options[:type] || :uniqueness label_object = ActiveBase.label_object(label) - fail_duplicate_constraint_or_index!(:constraint, label, property) if !force && label_object.constraint?(property) + if label_object.constraint?(property) + if force + label_object.drop_constraint(property, type: type) + else + fail_duplicate_constraint_or_index!(:constraint, label, property) + end + end label_object.create_constraint(property, type: type) end def add_index(label, property, options = {}) force = options[:force] || false label_object = ActiveBase.label_object(label) - fail_duplicate_constraint_or_index!(:index, label, property) if !force && label_object.index?(property) + if label_object.index?(property) + if force + label_object.drop_index(property) + else + fail_duplicate_constraint_or_index!(:index, label, property) + end + end label_object.create_index(property) end def drop_constraint(label, property, options = {}) type = options[:type] || :uniqueness