iTwin / imodel-transformer

API for exporting an iModel's parts and also importing them into another iModel
MIT License
3 stars 2 forks source link

Consider enforcing that the imodels passed to the BranchProvenanceInitializer are identical #138

Open nick4598 opened 6 months ago

nick4598 commented 6 months ago

initializeBranchProvenance function in BranchProvenanceInitializer.ts takes in ProvenanceInitArgs which contains a master and branch property of type IModelDb. Currently initializeBranchProvenance assumes that master and branch are identical, but that is not enforced.

How we could enforce it: Compare the hash of each element in the branch to the hash of the same element (with the same id) in master. Fail if not equal.

SELECT ECInstanceId
FROM bis.Element branchElem
JOIN master.bis.Element masterElem
WHERE sha3(branchElem.$) != sha3(masterElem.$)
LIMIT 1

We can repeat the above for relationships (bis.ElementRefersToElement) and aspects (bis.ElementMultiAspect, bis.ElementUniqueAspect).

The above seems sufficient, but we could also, in addition, compare the sha1 checksum of ec schemas, ec maps and db schemas.

PRAGMA checksum(ecdb_schema);

Concerns

Performance implications? How long will this take?