-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_trigger.sql
More file actions
26 lines (21 loc) · 962 Bytes
/
remove_trigger.sql
File metadata and controls
26 lines (21 loc) · 962 Bytes
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
-- Remove the database trigger if it exists
-- This ensures that the database doesn't try to send emails,
-- since the Frontend is now doing it directly.
DROP TRIGGER IF EXISTS on_order_created ON orders;
DROP FUNCTION IF EXISTS notify_admin_on_order();
-- Also ensure products are readable/updatable for stock management (Client-side logic)
ALTER TABLE products ENABLE ROW LEVEL SECURITY;
-- Allow authenticated users to view products (needed for checkout)
CREATE POLICY "Enable read access for all users"
ON products FOR SELECT
TO authenticated, anon
USING (true);
-- Allow authenticated users to update stock (needed for Checkout.tsx logic)
-- Note: In a stricter app, we would use an RPC function, but this matches the current frontend code.
CREATE POLICY "Enable stock update for authenticated users"
ON products FOR UPDATE
TO authenticated
USING (true)
WITH CHECK (true);
GRANT ALL ON products TO authenticated;
GRANT ALL ON products TO anon;