-- ============================================
-- 此文件由 Meoo Cloud 自动生成，请勿修改
-- This file is auto-generated by Meoo Cloud, DO NOT MODIFY
-- ============================================


-- 更新 inventory_records 的 company_id（通过 warehouse 关联）
UPDATE public.inventory_records ir
SET company_id = w.company_id
FROM public.warehouses w
WHERE ir.warehouse_id = w.id
AND ir.company_id IS NULL;

-- 更新 yarn_ratios 的 company_id（通过 production_plans 关联）
UPDATE public.yarn_ratios yr
SET company_id = pp.purchaser_id
FROM public.production_plans pp
WHERE yr.plan_id = pp.id
AND yr.company_id IS NULL;

-- 更新 plan_process_steps 的 company_id（通过 production_plans 关联）
UPDATE public.plan_process_steps pps
SET company_id = pp.purchaser_id
FROM public.production_plans pp
WHERE pps.plan_id = pp.id
AND pps.company_id IS NULL;

