Files
medical-mall/docs/sql/20_rls/finance/ml_invoices_rls_v1.sql

20 lines
782 B
SQL
Raw 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.
-- =====================================================================================
-- RLS: 发票管理表
-- 位置docs/sql/20_rls/finance/ml_invoices_rls_v1.sql
-- 对象类型RLS 策略
-- 版本v1
-- 说明:用户仅能查看自己的开票申请;管理端通过 RPC 访问
-- =====================================================================================
ALTER TABLE public.ml_invoices ENABLE ROW LEVEL SECURITY;
-- 策略 1: 允许用户读取自己的记录
DROP POLICY IF EXISTS ml_invoices_user_select ON public.ml_invoices;
CREATE POLICY ml_invoices_user_select
ON public.ml_invoices
FOR SELECT
TO authenticated
USING (uid = auth.uid());
-- 默认不开放 INSERT/UPDATE/DELETE 给普通用户,通常由 RPC 或支付后逻辑触发