-- ==================================================================== -- 0060_push_subscriptions — Web-Push-Abos fürs Mitarbeiter-Portal -- ==================================================================== -- Jede:r Mitarbeiter:in kann im Portal-PWA Push-Benachrichtigungen -- aktivieren (neue Leads/Terminanfragen/Buchungen). Ein Gerät = ein Abo -- (endpoint eindeutig). Zugriff ausschließlich über Service-Role (Portal- -- Actions, employeeId-gescoped) — kein anon-Zugriff. create table if not exists public.push_subscriptions ( id uuid primary key default gen_random_uuid(), employee_id uuid not null references public.employees(id) on delete cascade, endpoint text not null unique, p256dh text not null, auth text not null, user_agent text, created_at timestamptz not null default now(), last_used_at timestamptz ); create index if not exists push_subscriptions_employee_idx on public.push_subscriptions (employee_id); -- RLS an, keine anon-Policy → Default-Deny für anon. Service-Role umgeht RLS. alter table public.push_subscriptions enable row level security; revoke all on public.push_subscriptions from anon;