public ConstraintDefinition _createConstrant(Label label, String key) { Schema schema = graphDb.schema(); for (ConstraintDefinition constraint : schema.getConstraints(label)) for (String property : constraint.getPropertyKeys()) if (property.equals(key)) return constraint; // already existing return schema.constraintFor(label).assertPropertyIsUnique(key).create(); }