iloom-flatten/migrations/20260523_191350_add_notifications_rls.sql

21 lines
715 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.

-- ============================================
-- 此文件由 Meoo Cloud 自动生成,请勿修改
-- This file is auto-generated by Meoo Cloud, DO NOT MODIFY
-- ============================================
ALTER TABLE notifications ENABLE ROW LEVEL SECURITY;
-- 用户只能查看自己的通知
CREATE POLICY users_select_own_notifications ON notifications
FOR SELECT USING (recipient_id = auth.uid());
-- 用户只能标记自己的通知为已读
CREATE POLICY users_update_own_notifications ON notifications
FOR UPDATE USING (recipient_id = auth.uid());
-- 系统可以插入通知(通过 service role
CREATE POLICY service_insert_notifications ON notifications
FOR INSERT WITH CHECK (true);