-- ================================================================
-- DEV / TEST CLEANUP ONLY
-- 仅停用 DEV_HOME_SERVICE_PACKAGE_V1 批次的居家服务测试套餐。
-- 如已有测试订单引用这些套餐，请保留订单金额快照，不要直接物理删除。
-- 推荐执行时机：正式套餐导入完成且生产联调验证通过后。
-- ================================================================

BEGIN;

-- 执行前建议先人工确认以下记录：
-- SELECT id, service_id, package_name, status, data_source, seed_batch_no, deleted_at
-- FROM public.hss_service_packages
-- WHERE data_source = 'dev_seed'
--   AND seed_batch_no = 'DEV_HOME_SERVICE_PACKAGE_V1'
-- ORDER BY service_id, sort_no;

UPDATE public.hss_service_packages
SET
  status = 0,
  deleted_at = COALESCE(deleted_at, now()),
  updated_at = now(),
  remark = CASE
    WHEN remark = '' THEN 'DEV_HOME_SERVICE_PACKAGE_V1 已执行 cleanup 停用。'
    WHEN remark LIKE '%cleanup 停用%' THEN remark
    ELSE remark || ' DEV_HOME_SERVICE_PACKAGE_V1 已执行 cleanup 停用。'
  END
WHERE data_source = 'dev_seed'
  AND seed_batch_no = 'DEV_HOME_SERVICE_PACKAGE_V1';

COMMIT;