-- The edited version belongs to the photo whose edits produced it. Copies made -- before the fix still carried the edit bindings, so a photo without edit -- parameters showed the edited picture. Drop those bindings: the objects -- become collectable garbage and the copies show the original picture again. DELETE FROM photo_objects WHERE role IN ('edit', 'edit_thumb', 'edit_medium', 'edit_preview') AND photo_id IN ( SELECT id FROM photos WHERE edit_params IS NULL OR edit_params = '{}'::jsonb );