Files
glass/supabase/migrations/005_orders_public_token.sql
T
houseassassin 3df6029f89 feat: client portal — public order tracking page at /track/:token
Adds anonymous order tracking via a unique public_token UUID on each order,
a standalone React page at /track/:token, and a share button in OrderModal.
2026-05-10 17:27:15 +03:00

12 lines
532 B
SQL

-- Add public_token column to orders for anonymous order tracking
ALTER TABLE orders ADD COLUMN IF NOT EXISTS public_token UUID DEFAULT gen_random_uuid();
-- Backfill existing orders that have NULL public_token
UPDATE orders SET public_token = gen_random_uuid() WHERE public_token IS NULL;
-- Allow anon role to read orders if they know the public_token
-- (filtered further in app code via .eq('public_token', token))
CREATE POLICY "orders_read_by_public_token" ON orders
FOR SELECT TO anon
USING (public_token IS NOT NULL);