Unique Constraint on string

can’t I do an upsert query in DQL by indexing over containerId making a lookup of it keeping the uid and patching the entity with the correct uid ?