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


-- 为 products 表添加 RLS 策略
-- 允许查看（用于仓库同步），但只允许公司自己管理
CREATE POLICY users_select_products ON public.products
FOR SELECT USING (true);

CREATE POLICY users_insert_products ON public.products
FOR INSERT WITH CHECK (
 company_id = public.get_user_master_company_id()
);

CREATE POLICY users_update_products ON public.products
FOR UPDATE USING (
 company_id = public.get_user_master_company_id()
);

CREATE POLICY users_delete_products ON public.products
FOR DELETE USING (
 company_id = public.get_user_master_company_id()
);

-- 为 product_inventory_records 表添加 RLS 策略
CREATE POLICY users_select_product_inventory ON public.product_inventory_records
FOR SELECT USING (true);

CREATE POLICY users_insert_product_inventory ON public.product_inventory_records
FOR INSERT WITH CHECK (true);

CREATE POLICY users_update_product_inventory ON public.product_inventory_records
FOR UPDATE USING (true);

CREATE POLICY users_delete_product_inventory ON public.product_inventory_records
FOR DELETE USING (true);

-- 为 product_yarn_ratios 表添加 RLS 策略
CREATE POLICY users_select_product_yarn_ratios ON public.product_yarn_ratios
FOR SELECT USING (true);

CREATE POLICY users_insert_product_yarn_ratios ON public.product_yarn_ratios
FOR INSERT WITH CHECK (true);

CREATE POLICY users_update_product_yarn_ratios ON public.product_yarn_ratios
FOR UPDATE USING (true);

CREATE POLICY users_delete_product_yarn_ratios ON public.product_yarn_ratios
FOR DELETE USING (true);

