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


-- 创建辅助函数：获取当前用户的公司ID
CREATE OR REPLACE FUNCTION public.get_current_user_company_id()
RETURNS UUID
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = public
AS $$
DECLARE
 company_id UUID;
BEGIN
 SELECT p.company_id INTO company_id
 FROM public.profiles p
 WHERE p.id = auth.uid();
 RETURN company_id;
END;
$$;

