-- 回滚图片生成积分流水备注，仅处理仍可关联到独立图片生成任务的记录。
UPDATE public.point_ledger AS ledger
SET remark = CASE ledger.remark
    WHEN '图片生成' THEN '图片生成生成'
    WHEN '图片生成入队失败返还' THEN '图片生成生成入队失败返还'
END
WHERE ledger.remark IN ('图片生成', '图片生成入队失败返还')
  AND EXISTS (
      SELECT 1
      FROM public.generation_tasks AS task
      WHERE task.id::text = ledger.business_id
        AND task.task_type = 'image_generation'
        AND task.input_data->>'product_image' = 'true'
  );
