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


-- production_plans 表 RLS 策略
-- 采购商可以查看、修改、删除自己创建的计划
CREATE POLICY purchaser_select_plans ON public.production_plans
FOR SELECT USING (
 purchaser_id = public.get_user_master_company_id()
);

CREATE POLICY purchaser_insert_plans ON public.production_plans
FOR INSERT WITH CHECK (
 purchaser_id = public.get_user_master_company_id()
);

CREATE POLICY purchaser_update_plans ON public.production_plans
FOR UPDATE USING (
 purchaser_id = public.get_user_master_company_id()
);

CREATE POLICY purchaser_delete_plans ON public.production_plans
FOR DELETE USING (
 purchaser_id = public.get_user_master_company_id()
);

-- 工厂可以查看关联的计划（通过 plan_factories 关联）
-- 这个策略需要配合 plan_factories 的查询

