Best way to add multiple artifacts to uniqueness constraints

I have a content type using MultipleArtifactContentSerializer i.e. “can be associated with multiple artifacts”.

I now need to ensure, that any change in any of the associated artifacts results in a new content unit (rather than a modification of the existing one). In other words, I need to add the checksum of all associated artifacts, to the “unique together” condition of the content unit.

Just so I don’t reinvent the wheel, I was wondering if there is already an example for such a content type in some Pulp plugin somewhere?

I can’t seem to find any list types in django.db.models other than JSONField, the alternative to a list of sha256 checksums might be a sha256 checksum over several checksums, but neither solution strikes me as very elegant. (I don’t want an identical set of artifacts to come up as “different”, because the order that the artifact checksums are processed in has changed).

Update: After some discussion with @x9c4 I am now pursuing the following approach:

I will go over the possible artifacts in a fixed order, concatenate the sha256 checksums, create a checksum of checksums, call that the artifact_set_sha256 and add that to the uniqueness constraints.

1 Like