The create_item function was missing ON CONFLICT DO NOTHING for insertions into the ItemUpload table as in update_item. This means that if the same image was used multiple times in the same item, creation failed. But it worked during editing.