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


-- 删除旧的 RLS 策略
DROP POLICY IF EXISTS users_select_yarn_ratios ON public.yarn_ratios;
DROP POLICY IF EXISTS users_insert_yarn_ratios ON public.yarn_ratios;
DROP POLICY IF EXISTS users_delete_yarn_ratios ON public.yarn_ratios;

-- 创建优化的 RLS 策略（直接使用 company_id）
CREATE POLICY users_select_yarn_ratios ON public.yarn_ratios
FOR SELECT USING (
 company_id = public.get_user_master_company_id()
);

CREATE POLICY users_insert_yarn_ratios ON public.yarn_ratios
FOR INSERT WITH CHECK (
 company_id = public.get_user_master_company_id()
);

CREATE POLICY users_update_yarn_ratios ON public.yarn_ratios
FOR UPDATE USING (
 company_id = public.get_user_master_company_id()
);

CREATE POLICY users_delete_yarn_ratios ON public.yarn_ratios
FOR DELETE USING (
 company_id = public.get_user_master_company_id()
);

