diff --git a/client/document.go b/client/document.go index ccbdfd688c..ada47cc8f9 100644 --- a/client/document.go +++ b/client/document.go @@ -777,6 +777,11 @@ func (doc *Document) GenerateDocID() (DocID, error) { return DocID{}, err } + // The DocID must take into consideration the schema root, this ensures that + // otherwise identical documents created using different schema will have different + // document IDs - we do not want cross-schema docID collisions. + bytes = append(bytes, []byte(doc.collectionDefinition.Schema.Root)...) + cid, err := ccid.NewSHA256CidV1(bytes) if err != nil { return DocID{}, err