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


-- 修复 profiles 策略中的 uid() 为 auth.uid()
DROP POLICY IF EXISTS users_select_company_profiles ON public.profiles;
DROP POLICY IF EXISTS users_update_own_profile ON public.profiles;

-- 重新创建正确的策略
CREATE POLICY users_select_company_profiles ON public.profiles
FOR SELECT USING (
 company_id = public.get_user_master_company_id() 
 OR id = auth.uid()
);

CREATE POLICY users_update_own_profile ON public.profiles
FOR UPDATE USING (
 id = auth.uid()
);

