af9e7ce1af
- Push notifications: custom SW (injectManifest), usePushNotifications hook, push-notify Edge Function, push_subscriptions migration, bell toggle in header - Calendar view: month-grid CalendarPage + useCalendar hook, scheduled_at column migration, datetime field in OrderModal, CalendarDays nav item + route - Photo attachments: useOrderPhotos hook, photo gallery/upload in OrderModal (edit mode), order-photos Storage bucket migration with RLS policies Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
19 lines
712 B
SQL
19 lines
712 B
SQL
-- Push notification subscriptions
|
|
-- One row per user. The subscription JSONB holds the PushSubscription JSON
|
|
-- (endpoint, keys.p256dh, keys.auth) returned by the browser PushManager.
|
|
CREATE TABLE push_subscriptions (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
subscription JSONB NOT NULL,
|
|
created_at TIMESTAMPTZ DEFAULT now(),
|
|
UNIQUE (user_id)
|
|
);
|
|
|
|
ALTER TABLE push_subscriptions ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- Admins can only manage their own subscription
|
|
CREATE POLICY "Users manage own subscriptions"
|
|
ON push_subscriptions
|
|
USING (auth.uid() = user_id)
|
|
WITH CHECK (auth.uid() = user_id);
|