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

21 lines
880 B
SQL
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.
-- =====================================================================================
-- RLS: 用户提现申请表
-- 位置docs/sql/20_rls/finance/
-- 对象类型RLS 策略
-- 版本v1
-- 说明:仅允许用户查看自己的提现记录;管理端通过 RPC 访问
-- =====================================================================================
ALTER TABLE public.ml_extract ENABLE ROW LEVEL SECURITY;
-- 策略 1: 允许用户读取自己的提现申请
DROP POLICY IF EXISTS ml_extract_user_select ON public.ml_extract;
CREATE POLICY ml_extract_user_select
ON public.ml_extract
FOR SELECT
TO authenticated
USING (uid = auth.uid() AND deleted_at IS NULL);
-- 默认不开放 INSERT/UPDATE/DELETE 给普通用户
-- 提现申请通常由特定的 RPC 函数 (security definer) 创建,以确保业务逻辑(如冻结余额)的原子性