iloom-flatten/migrations/20260523_162428_create_helper_function_1.sql

24 lines
558 B
PL/PgSQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ============================================
-- 此文件由 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;
$$;