ETest-Vue-FastAPI/update_old_workorder_batch_...

20 lines
416 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- 更新旧工单的 batch_name如果为空
-- 使用 batch_id 生成默认的 batch_name
UPDATE test_work_order
SET batch_name = CONCAT('批次-', FROM_UNIXTIME(batch_id/1000, '%Y%m%d%H%i%s'))
WHERE batch_name IS NULL
AND batch_id IS NOT NULL;
-- 验证更新
SELECT
id,
batch_id,
batch_name,
name,
create_time
FROM test_work_order
WHERE order_id IS NULL
ORDER BY id DESC
LIMIT 20;