- Add push_subscriptions pgTable with endpoint, p256dh, auth, userId, companyId, deviceLabel - Add 0055_create_push_subscriptions.sql migration with CREATE TABLE and endpoint index - Export pushSubscriptions from schema/index.ts - Create pushService with initVapid, getVapidPublicKey, saveSubscription, removeSubscription, sendPushToAll - sendPushToAll auto-deletes stale subscriptions on 410/404 response - Create pushRoutes: GET /vapid-public-key, POST /subscribe, DELETE /subscribe - Mount /api/push routes and call initVapid() in app.ts with graceful skip - Install web-push and @types/web-push
12 lines
406 B
SQL
12 lines
406 B
SQL
CREATE TABLE IF NOT EXISTS "push_subscriptions" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"endpoint" text NOT NULL,
|
|
"p256dh" text NOT NULL,
|
|
"auth" text NOT NULL,
|
|
"user_id" uuid,
|
|
"company_id" uuid,
|
|
"device_label" text,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "push_sub_endpoint_idx" ON "push_subscriptions" ("endpoint");
|