-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-missing-update-policies.sql
More file actions
53 lines (44 loc) · 1.92 KB
/
Copy pathadd-missing-update-policies.sql
File metadata and controls
53 lines (44 loc) · 1.92 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
-- Add missing UPDATE policies for privacy toggle functionality
-- This script only adds the UPDATE policies that are missing
-- ========================================
-- CITIES TABLE - Add UPDATE policy
-- ========================================
-- Drop existing update policy if it exists
DROP POLICY IF EXISTS "Allow users to update own cities" ON cities;
-- Create UPDATE policy for cities
CREATE POLICY "Allow users to update own cities" ON cities
FOR UPDATE
USING (auth.uid()::text = created_by);
-- ========================================
-- INTERVENTIONS TABLE - Add UPDATE policy
-- ========================================
-- Drop existing update policy if it exists
DROP POLICY IF EXISTS "Allow users to update own interventions" ON interventions;
-- Create UPDATE policy for interventions
CREATE POLICY "Allow users to update own interventions" ON interventions
FOR UPDATE
USING (auth.uid()::text = created_by);
-- ========================================
-- SCENARIOS TABLE - Add UPDATE policy
-- ========================================
-- Drop existing update policy if it exists
DROP POLICY IF EXISTS "Allow users to update own scenarios" ON scenarios;
-- Create UPDATE policy for scenarios
CREATE POLICY "Allow users to update own scenarios" ON scenarios
FOR UPDATE
USING (auth.uid()::text = created_by);
-- ========================================
-- Verify policies were created
-- ========================================
-- Check cities policies
SELECT schemaname, tablename, policyname, permissive, roles, cmd, qual
FROM pg_policies
WHERE tablename = 'cities' AND cmd = 'UPDATE';
-- Check interventions policies
SELECT schemaname, tablename, policyname, permissive, roles, cmd, qual
FROM pg_policies
WHERE tablename = 'interventions' AND cmd = 'UPDATE';
-- Check scenarios policies
SELECT schemaname, tablename, policyname, permissive, roles, cmd, qual
FROM pg_policies
WHERE tablename = 'scenarios' AND cmd = 'UPDATE';