feature: version one notification feature implemented.

This commit is contained in:
2026-07-18 01:09:54 +03:30
parent 0740493384
commit 9f6ec193d2
40 changed files with 1679 additions and 224 deletions

View File

@@ -0,0 +1,41 @@
-- CreateEnum
CREATE TYPE "UserNotificationType" AS ENUM (
'CASE_SENT',
'CLINIC_COMMENT',
'LAB_COMMENT',
'LAB_COMMENT_CLINIC',
'CASE_IMPORTANT',
'TASK_COMPLETED',
'TASK_ASSIGNED',
'CONNECTION_REQUEST',
'STAFF_INVITE'
);
-- CreateTable
CREATE TABLE "user_notifications" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"type" "UserNotificationType" NOT NULL,
"actorUserId" TEXT,
"payload" JSONB,
"href" TEXT NOT NULL,
"readAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "user_notifications_pkey" PRIMARY KEY ("id")
);
CREATE INDEX "user_notifications_userId_organizationId_createdAt_idx"
ON "user_notifications"("userId", "organizationId", "createdAt");
CREATE INDEX "user_notifications_userId_organizationId_readAt_idx"
ON "user_notifications"("userId", "organizationId", "readAt");
ALTER TABLE "user_notifications"
ADD CONSTRAINT "user_notifications_userId_fkey"
FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "user_notifications"
ADD CONSTRAINT "user_notifications_actorUserId_fkey"
FOREIGN KEY ("actorUserId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;