-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_rls_issues.sql
More file actions
63 lines (51 loc) · 1.87 KB
/
Copy pathfix_rls_issues.sql
File metadata and controls
63 lines (51 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Fix RLS policy errors for fresh users
-- ================================
-- CLIENTS TABLE RLS POLICIES
-- ================================
-- Drop existing policies
DROP POLICY IF EXISTS "Users can view their own clients" ON clients;
DROP POLICY IF EXISTS "Users can insert their own clients" ON clients;
DROP POLICY IF EXISTS "Users can update their own clients" ON clients;
DROP POLICY IF EXISTS "Users can delete their own clients" ON clients;
-- Create more permissive policies for fresh users
CREATE POLICY "Users can view all clients"
ON clients FOR SELECT
TO authenticated
USING (true);
CREATE POLICY "Users can insert clients"
ON clients FOR INSERT
TO authenticated
WITH CHECK (true);
CREATE POLICY "Users can update clients"
ON clients FOR UPDATE
TO authenticated
USING (true);
CREATE POLICY "Users can delete clients"
ON clients FOR DELETE
TO authenticated
USING (true);
-- ================================
-- FINANCIAL_PLANS TABLE RLS POLICIES
-- ================================
-- Drop existing policies
DROP POLICY IF EXISTS "Users can view their own financial plans" ON financial_plans;
DROP POLICY IF EXISTS "Users can insert their own financial plans" ON financial_plans;
DROP POLICY IF EXISTS "Users can update their own financial plans" ON financial_plans;
DROP POLICY IF EXISTS "Users can delete financial plans for clients they can access" ON financial_plans;
-- Create more permissive policies for fresh users
CREATE POLICY "Users can view all financial plans"
ON financial_plans FOR SELECT
TO authenticated
USING (true);
CREATE POLICY "Users can insert financial plans"
ON financial_plans FOR INSERT
TO authenticated
WITH CHECK (true);
CREATE POLICY "Users can update financial plans"
ON financial_plans FOR UPDATE
TO authenticated
USING (true);
CREATE POLICY "Users can delete financial plans"
ON financial_plans FOR DELETE
TO authenticated
USING (true);