@varaos/db 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
-- Migration: add_notification_enhancements_and_refresh_token
|
|
2
|
+
-- Description:
|
|
3
|
+
-- 1. Add refreshTokenExpiresAt to Integration for proactive token expiry tracking
|
|
4
|
+
-- 2. Enhance Notification model with readAt, actionUrl, metadata, indexes
|
|
5
|
+
-- 3. Update Notification FK to CASCADE on user deletion
|
|
6
|
+
|
|
7
|
+
-- ============================================================
|
|
8
|
+
-- 1. Integration: Add refreshTokenExpiresAt
|
|
9
|
+
-- ============================================================
|
|
10
|
+
|
|
11
|
+
-- AlterTable
|
|
12
|
+
ALTER TABLE "integrations" ADD COLUMN "refreshTokenExpiresAt" TIMESTAMP(3);
|
|
13
|
+
|
|
14
|
+
-- ============================================================
|
|
15
|
+
-- 2. Notification: Add new columns
|
|
16
|
+
-- ============================================================
|
|
17
|
+
|
|
18
|
+
-- AlterTable
|
|
19
|
+
ALTER TABLE "Notification" ADD COLUMN "readAt" TIMESTAMP(3);
|
|
20
|
+
ALTER TABLE "Notification" ADD COLUMN "actionUrl" TEXT;
|
|
21
|
+
ALTER TABLE "Notification" ADD COLUMN "metadata" JSONB;
|
|
22
|
+
|
|
23
|
+
-- ============================================================
|
|
24
|
+
-- 3. Notification: Update FK to ON DELETE CASCADE
|
|
25
|
+
-- ============================================================
|
|
26
|
+
|
|
27
|
+
-- DropForeignKey (old: ON DELETE SET NULL)
|
|
28
|
+
ALTER TABLE "Notification" DROP CONSTRAINT "Notification_userId_fkey";
|
|
29
|
+
|
|
30
|
+
-- AddForeignKey (new: ON DELETE CASCADE)
|
|
31
|
+
ALTER TABLE "Notification" ADD CONSTRAINT "Notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
32
|
+
|
|
33
|
+
-- ============================================================
|
|
34
|
+
-- 4. Notification: Add performance indexes
|
|
35
|
+
-- ============================================================
|
|
36
|
+
|
|
37
|
+
-- CreateIndex
|
|
38
|
+
CREATE INDEX "Notification_userId_read_idx" ON "Notification"("userId", "read");
|
|
39
|
+
|
|
40
|
+
-- CreateIndex
|
|
41
|
+
CREATE INDEX "Notification_userId_createdAt_idx" ON "Notification"("userId", "createdAt");
|
|
42
|
+
|
|
43
|
+
-- CreateIndex
|
|
44
|
+
CREATE INDEX "Notification_type_idx" ON "Notification"("type");
|
package/prisma/schema.prisma
CHANGED
|
@@ -564,6 +564,7 @@ model Integration {
|
|
|
564
564
|
accessToken String
|
|
565
565
|
refreshToken String?
|
|
566
566
|
expiresAt DateTime?
|
|
567
|
+
refreshTokenExpiresAt DateTime?
|
|
567
568
|
scopes Json
|
|
568
569
|
profile Json
|
|
569
570
|
status IntegrationStatus @default(active)
|
|
@@ -1092,14 +1093,26 @@ model ConversationSummary {
|
|
|
1092
1093
|
model Notification {
|
|
1093
1094
|
id String @id @default(uuid())
|
|
1094
1095
|
userId String?
|
|
1095
|
-
|
|
1096
|
+
|
|
1097
|
+
type String // workflow_started, workflow_completed, workflow_failed, integration_expired, system
|
|
1096
1098
|
title String
|
|
1097
|
-
body String?
|
|
1098
|
-
|
|
1099
|
+
body String? @db.Text
|
|
1100
|
+
|
|
1101
|
+
read Boolean @default(false)
|
|
1102
|
+
readAt DateTime?
|
|
1103
|
+
|
|
1104
|
+
/// Optional deep link (e.g. "/integrations/google-gmail" or "/automations/abc")
|
|
1105
|
+
actionUrl String?
|
|
1106
|
+
|
|
1107
|
+
metadata Json?
|
|
1099
1108
|
|
|
1100
1109
|
createdAt DateTime @default(now())
|
|
1101
1110
|
|
|
1102
|
-
user User? @relation(fields: [userId], references: [id])
|
|
1111
|
+
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1112
|
+
|
|
1113
|
+
@@index([userId, read])
|
|
1114
|
+
@@index([userId, createdAt])
|
|
1115
|
+
@@index([type])
|
|
1103
1116
|
}
|
|
1104
1117
|
|
|
1105
1118
|
model ChatSession {
|
|
@@ -2124,6 +2137,7 @@ model DeadLetterJob {
|
|
|
2124
2137
|
}
|
|
2125
2138
|
|
|
2126
2139
|
|
|
2140
|
+
|
|
2127
2141
|
/// ─────────────────────────────────────────────────────────────
|
|
2128
2142
|
/// ADMIN USER MANAGEMENT (For SaaS Admin Panel)
|
|
2129
2143
|
/// ─────────────────────────────────────────────────────────────
|