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


-- 删除旧的 RLS 策略
DROP POLICY IF EXISTS users_select_company_inventory ON public.inventory_records;
DROP POLICY IF EXISTS users_insert_company_inventory ON public.inventory_records;

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

CREATE POLICY users_insert_company_inventory ON public.inventory_records
FOR INSERT WITH CHECK (
 company_id = public.get_user_master_company_id()
);

CREATE POLICY users_update_company_inventory ON public.inventory_records
FOR UPDATE USING (
 company_id = public.get_user_master_company_id()
);

CREATE POLICY users_delete_company_inventory ON public.inventory_records
FOR DELETE USING (
 company_id = public.get_user_master_company_id()
);

