@juliobrim/prisma-shared 1.0.54 → 1.0.56
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.
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
-- CreateEnum
|
|
2
|
+
CREATE TYPE "SupportConversationStatus" AS ENUM ('OPEN', 'CLOSED');
|
|
3
|
+
|
|
4
|
+
-- CreateEnum
|
|
5
|
+
CREATE TYPE "SupportMessageSenderType" AS ENUM ('USER', 'SUPPORT');
|
|
6
|
+
|
|
7
|
+
-- CreateTable
|
|
8
|
+
CREATE TABLE "support_conversation" (
|
|
9
|
+
"id" TEXT NOT NULL,
|
|
10
|
+
"tenantId" TEXT NOT NULL,
|
|
11
|
+
"userId" TEXT NOT NULL,
|
|
12
|
+
"assignedSupportUserId" TEXT,
|
|
13
|
+
"status" "SupportConversationStatus" NOT NULL DEFAULT 'OPEN',
|
|
14
|
+
"lastMessageAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
15
|
+
"lastMessagePreview" VARCHAR(180),
|
|
16
|
+
"unreadForUserCount" INTEGER NOT NULL DEFAULT 0,
|
|
17
|
+
"unreadForSupportCount" INTEGER NOT NULL DEFAULT 0,
|
|
18
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
19
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
20
|
+
|
|
21
|
+
CONSTRAINT "support_conversation_pkey" PRIMARY KEY ("id")
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
-- CreateTable
|
|
25
|
+
CREATE TABLE "support_message" (
|
|
26
|
+
"id" TEXT NOT NULL,
|
|
27
|
+
"conversationId" TEXT NOT NULL,
|
|
28
|
+
"tenantId" TEXT NOT NULL,
|
|
29
|
+
"senderType" "SupportMessageSenderType" NOT NULL,
|
|
30
|
+
"senderUserId" TEXT,
|
|
31
|
+
"body" TEXT,
|
|
32
|
+
"attachmentUrl" TEXT,
|
|
33
|
+
"attachmentName" VARCHAR(255),
|
|
34
|
+
"attachmentMimeType" VARCHAR(120),
|
|
35
|
+
"attachmentSize" INTEGER,
|
|
36
|
+
"readAt" TIMESTAMP(3),
|
|
37
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
38
|
+
|
|
39
|
+
CONSTRAINT "support_message_pkey" PRIMARY KEY ("id")
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
-- CreateIndex
|
|
43
|
+
CREATE INDEX "support_conversation_tenantId_status_lastMessageAt_idx" ON "support_conversation"("tenantId", "status", "lastMessageAt");
|
|
44
|
+
|
|
45
|
+
-- CreateIndex
|
|
46
|
+
CREATE INDEX "support_conversation_tenantId_unreadForSupportCount_lastMes_idx" ON "support_conversation"("tenantId", "unreadForSupportCount", "lastMessageAt");
|
|
47
|
+
|
|
48
|
+
-- CreateIndex
|
|
49
|
+
CREATE UNIQUE INDEX "support_conversation_tenantId_userId_key" ON "support_conversation"("tenantId", "userId");
|
|
50
|
+
|
|
51
|
+
-- CreateIndex
|
|
52
|
+
CREATE INDEX "support_message_conversationId_createdAt_idx" ON "support_message"("conversationId", "createdAt");
|
|
53
|
+
|
|
54
|
+
-- CreateIndex
|
|
55
|
+
CREATE INDEX "support_message_tenantId_createdAt_idx" ON "support_message"("tenantId", "createdAt");
|
|
56
|
+
|
|
57
|
+
-- AddForeignKey
|
|
58
|
+
ALTER TABLE "support_conversation" ADD CONSTRAINT "support_conversation_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
59
|
+
|
|
60
|
+
-- AddForeignKey
|
|
61
|
+
ALTER TABLE "support_conversation" ADD CONSTRAINT "support_conversation_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
62
|
+
|
|
63
|
+
-- AddForeignKey
|
|
64
|
+
ALTER TABLE "support_conversation" ADD CONSTRAINT "support_conversation_assignedSupportUserId_fkey" FOREIGN KEY ("assignedSupportUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
65
|
+
|
|
66
|
+
-- AddForeignKey
|
|
67
|
+
ALTER TABLE "support_message" ADD CONSTRAINT "support_message_conversationId_fkey" FOREIGN KEY ("conversationId") REFERENCES "support_conversation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
68
|
+
|
|
69
|
+
-- AddForeignKey
|
|
70
|
+
ALTER TABLE "support_message" ADD CONSTRAINT "support_message_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
71
|
+
|
|
72
|
+
-- AddForeignKey
|
|
73
|
+
ALTER TABLE "support_message" ADD CONSTRAINT "support_message_senderUserId_fkey" FOREIGN KEY ("senderUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
-- CreateEnum
|
|
2
|
+
CREATE TYPE "StatisticsSourceType" AS ENUM ('CLOSED', 'DYNAMIC');
|
|
3
|
+
|
|
4
|
+
-- CreateTable
|
|
5
|
+
CREATE TABLE "oee_interval_fact" (
|
|
6
|
+
"id" TEXT NOT NULL,
|
|
7
|
+
"tenantId" TEXT NOT NULL,
|
|
8
|
+
"machineId" TEXT NOT NULL,
|
|
9
|
+
"operatorId" TEXT,
|
|
10
|
+
"operationId" TEXT,
|
|
11
|
+
"operationGroupId" INTEGER,
|
|
12
|
+
"productionOrderId" TEXT,
|
|
13
|
+
"productId" TEXT,
|
|
14
|
+
"shiftId" TEXT,
|
|
15
|
+
"date" DATE NOT NULL,
|
|
16
|
+
"windowStart" TIMESTAMP(6) NOT NULL,
|
|
17
|
+
"windowEnd" TIMESTAMP(6) NOT NULL,
|
|
18
|
+
"sourceType" "StatisticsSourceType" NOT NULL,
|
|
19
|
+
"calculationVersion" INTEGER NOT NULL DEFAULT 1,
|
|
20
|
+
"generatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
21
|
+
"plannedSeconds" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
22
|
+
"breakSeconds" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
23
|
+
"grossSpanSeconds" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
24
|
+
"runtimeSeconds" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
25
|
+
"impactfulDowntimeSeconds" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
26
|
+
"nonImpactfulDowntimeSeconds" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
27
|
+
"unjustifiedDowntimeSeconds" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
28
|
+
"producedQty" INTEGER NOT NULL DEFAULT 0,
|
|
29
|
+
"rejectedQty" INTEGER NOT NULL DEFAULT 0,
|
|
30
|
+
"goodQty" INTEGER NOT NULL DEFAULT 0,
|
|
31
|
+
"idealCycleTimeSeconds" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
32
|
+
"performance" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
33
|
+
"availability" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
34
|
+
"quality" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
35
|
+
"oee" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
36
|
+
|
|
37
|
+
CONSTRAINT "oee_interval_fact_pkey" PRIMARY KEY ("id")
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
-- CreateIndex
|
|
41
|
+
CREATE INDEX "oee_interval_fact_tenantId_date_idx" ON "oee_interval_fact"("tenantId", "date");
|
|
42
|
+
|
|
43
|
+
-- CreateIndex
|
|
44
|
+
CREATE INDEX "oee_interval_fact_tenantId_machineId_windowStart_idx" ON "oee_interval_fact"("tenantId", "machineId", "windowStart");
|
|
45
|
+
|
|
46
|
+
-- CreateIndex
|
|
47
|
+
CREATE INDEX "oee_interval_fact_tenantId_operatorId_windowStart_idx" ON "oee_interval_fact"("tenantId", "operatorId", "windowStart");
|
|
48
|
+
|
|
49
|
+
-- CreateIndex
|
|
50
|
+
CREATE INDEX "oee_interval_fact_tenantId_operationId_windowStart_idx" ON "oee_interval_fact"("tenantId", "operationId", "windowStart");
|
|
51
|
+
|
|
52
|
+
-- CreateIndex
|
|
53
|
+
CREATE INDEX "oee_interval_fact_tenantId_productionOrderId_windowStart_idx" ON "oee_interval_fact"("tenantId", "productionOrderId", "windowStart");
|
|
54
|
+
|
|
55
|
+
-- CreateIndex
|
|
56
|
+
CREATE INDEX "oee_interval_fact_tenantId_sourceType_windowStart_idx" ON "oee_interval_fact"("tenantId", "sourceType", "windowStart");
|
|
57
|
+
|
|
58
|
+
-- AddForeignKey
|
|
59
|
+
ALTER TABLE "oee_interval_fact" ADD CONSTRAINT "oee_interval_fact_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
60
|
+
|
|
61
|
+
-- AddForeignKey
|
|
62
|
+
ALTER TABLE "oee_interval_fact" ADD CONSTRAINT "oee_interval_fact_machineId_fkey" FOREIGN KEY ("machineId") REFERENCES "machine"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
63
|
+
|
|
64
|
+
-- AddForeignKey
|
|
65
|
+
ALTER TABLE "oee_interval_fact" ADD CONSTRAINT "oee_interval_fact_operatorId_fkey" FOREIGN KEY ("operatorId") REFERENCES "operator"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
66
|
+
|
|
67
|
+
-- AddForeignKey
|
|
68
|
+
ALTER TABLE "oee_interval_fact" ADD CONSTRAINT "oee_interval_fact_operationId_fkey" FOREIGN KEY ("operationId") REFERENCES "operation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
69
|
+
|
|
70
|
+
-- AddForeignKey
|
|
71
|
+
ALTER TABLE "oee_interval_fact" ADD CONSTRAINT "oee_interval_fact_operationGroupId_fkey" FOREIGN KEY ("operationGroupId") REFERENCES "operation_group"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
72
|
+
|
|
73
|
+
-- AddForeignKey
|
|
74
|
+
ALTER TABLE "oee_interval_fact" ADD CONSTRAINT "oee_interval_fact_productionOrderId_fkey" FOREIGN KEY ("productionOrderId") REFERENCES "production_order"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
75
|
+
|
|
76
|
+
-- AddForeignKey
|
|
77
|
+
ALTER TABLE "oee_interval_fact" ADD CONSTRAINT "oee_interval_fact_productId_fkey" FOREIGN KEY ("productId") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
78
|
+
|
|
79
|
+
-- AddForeignKey
|
|
80
|
+
ALTER TABLE "oee_interval_fact" ADD CONSTRAINT "oee_interval_fact_shiftId_fkey" FOREIGN KEY ("shiftId") REFERENCES "shift"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -63,6 +63,9 @@ model Tenant {
|
|
|
63
63
|
operatorAvailability OperatorAvailabilityCache[]
|
|
64
64
|
qualityRegisters QualityRegister[]
|
|
65
65
|
qualityIssues QualityIssue[]
|
|
66
|
+
supportConversations SupportConversation[]
|
|
67
|
+
supportMessages SupportMessage[]
|
|
68
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
66
69
|
|
|
67
70
|
@@map("tenant")
|
|
68
71
|
}
|
|
@@ -285,6 +288,7 @@ model Machine {
|
|
|
285
288
|
machineOperationStitch MachineOperationStitch[]
|
|
286
289
|
productivityIntervals ProductivityIntervalCache[]
|
|
287
290
|
machineOperationalState MachineOperationalState?
|
|
291
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
288
292
|
|
|
289
293
|
@@unique([tenantId, name])
|
|
290
294
|
@@index([sectorId])
|
|
@@ -360,6 +364,66 @@ model NotificationToUser {
|
|
|
360
364
|
@@map("notification_to_user")
|
|
361
365
|
}
|
|
362
366
|
|
|
367
|
+
model OeeIntervalFact {
|
|
368
|
+
id String @id @default(cuid())
|
|
369
|
+
tenantId String
|
|
370
|
+
machineId String
|
|
371
|
+
operatorId String?
|
|
372
|
+
operationId String?
|
|
373
|
+
operationGroupId Int?
|
|
374
|
+
productionOrderId String?
|
|
375
|
+
productId String?
|
|
376
|
+
shiftId String?
|
|
377
|
+
|
|
378
|
+
date DateTime @db.Date
|
|
379
|
+
windowStart DateTime @db.Timestamp(6)
|
|
380
|
+
windowEnd DateTime @db.Timestamp(6)
|
|
381
|
+
|
|
382
|
+
sourceType StatisticsSourceType
|
|
383
|
+
calculationVersion Int @default(1)
|
|
384
|
+
generatedAt DateTime @default(now())
|
|
385
|
+
|
|
386
|
+
plannedSeconds Float @default(0)
|
|
387
|
+
breakSeconds Float @default(0)
|
|
388
|
+
grossSpanSeconds Float @default(0)
|
|
389
|
+
runtimeSeconds Float @default(0)
|
|
390
|
+
impactfulDowntimeSeconds Float @default(0)
|
|
391
|
+
nonImpactfulDowntimeSeconds Float @default(0)
|
|
392
|
+
unjustifiedDowntimeSeconds Float @default(0)
|
|
393
|
+
|
|
394
|
+
producedQty Int @default(0)
|
|
395
|
+
rejectedQty Int @default(0)
|
|
396
|
+
goodQty Int @default(0)
|
|
397
|
+
idealCycleTimeSeconds Float @default(0)
|
|
398
|
+
|
|
399
|
+
performance Float @default(0)
|
|
400
|
+
availability Float @default(0)
|
|
401
|
+
quality Float @default(0)
|
|
402
|
+
oee Float @default(0)
|
|
403
|
+
|
|
404
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
405
|
+
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
406
|
+
operator Operator? @relation(fields: [operatorId], references: [id], onDelete: Cascade)
|
|
407
|
+
operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
408
|
+
operationGroup OperationGroup? @relation(fields: [operationGroupId], references: [id], onDelete: Cascade)
|
|
409
|
+
productionOrder ProductionOrder? @relation(fields: [productionOrderId], references: [id], onDelete: Cascade)
|
|
410
|
+
product Product? @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
411
|
+
shift Shift? @relation(fields: [shiftId], references: [id], onDelete: SetNull)
|
|
412
|
+
|
|
413
|
+
@@index([tenantId, date])
|
|
414
|
+
@@index([tenantId, machineId, windowStart])
|
|
415
|
+
@@index([tenantId, operatorId, windowStart])
|
|
416
|
+
@@index([tenantId, operationId, windowStart])
|
|
417
|
+
@@index([tenantId, productionOrderId, windowStart])
|
|
418
|
+
@@index([tenantId, sourceType, windowStart])
|
|
419
|
+
@@map("oee_interval_fact")
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
enum StatisticsSourceType {
|
|
423
|
+
CLOSED
|
|
424
|
+
DYNAMIC
|
|
425
|
+
}
|
|
426
|
+
|
|
363
427
|
model Operation {
|
|
364
428
|
id String @id @default(cuid())
|
|
365
429
|
stitches Int
|
|
@@ -395,6 +459,7 @@ model Operation {
|
|
|
395
459
|
machineOperationStitch MachineOperationStitch[]
|
|
396
460
|
productivityIntervals ProductivityIntervalCache[]
|
|
397
461
|
qualityRegisters QualityRegister[]
|
|
462
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
398
463
|
|
|
399
464
|
@@index([nodeId], map: "idx_operation_node_id")
|
|
400
465
|
@@map("operation")
|
|
@@ -416,6 +481,7 @@ model OperationGroup {
|
|
|
416
481
|
operationRegisters OperationRegister[]
|
|
417
482
|
productionNodes ProductionNode[]
|
|
418
483
|
operations Operation[] @relation("OperationToOperationGroup")
|
|
484
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
419
485
|
|
|
420
486
|
@@map("operation_group")
|
|
421
487
|
}
|
|
@@ -509,6 +575,7 @@ model Operator {
|
|
|
509
575
|
productivityIntervals ProductivityIntervalCache[]
|
|
510
576
|
operatorAvailability OperatorAvailabilityCache[]
|
|
511
577
|
qualityRegisters QualityRegister[]
|
|
578
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
512
579
|
|
|
513
580
|
@@unique([tenantId, name])
|
|
514
581
|
@@index([tenantId, isDeleted])
|
|
@@ -581,6 +648,7 @@ model Product {
|
|
|
581
648
|
componentOf ProductComponents[] @relation("composedBy")
|
|
582
649
|
operations ProductToOperation[]
|
|
583
650
|
productionOrders ProductionOrder[]
|
|
651
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
584
652
|
|
|
585
653
|
@@index([tenantId])
|
|
586
654
|
@@index([isDeleted])
|
|
@@ -646,6 +714,7 @@ model ProductionOrder {
|
|
|
646
714
|
flow Flow? @relation(fields: [flowId], references: [id])
|
|
647
715
|
Product Product @relation(fields: [productId], references: [id])
|
|
648
716
|
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
717
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
649
718
|
|
|
650
719
|
@@unique([tenantId, productionOrderIndex])
|
|
651
720
|
@@index([tenantId, isFinished])
|
|
@@ -757,6 +826,7 @@ model Shift {
|
|
|
757
826
|
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
758
827
|
operators Operator[]
|
|
759
828
|
operatorAvailability OperatorAvailabilityCache[]
|
|
829
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
760
830
|
|
|
761
831
|
@@unique([tenantId, name])
|
|
762
832
|
@@map("shift")
|
|
@@ -812,22 +882,25 @@ model TwoFactorToken {
|
|
|
812
882
|
}
|
|
813
883
|
|
|
814
884
|
model User {
|
|
815
|
-
id
|
|
816
|
-
name
|
|
817
|
-
email
|
|
818
|
-
emailVerified
|
|
819
|
-
image
|
|
820
|
-
password
|
|
821
|
-
isTwoFactorEnabled
|
|
822
|
-
roleId
|
|
823
|
-
role
|
|
824
|
-
tenantId
|
|
825
|
-
accounts
|
|
826
|
-
follows
|
|
827
|
-
NotificationToUser
|
|
828
|
-
Panel
|
|
829
|
-
twoFactorConfirmation
|
|
830
|
-
tenant
|
|
885
|
+
id String @id @default(uuid())
|
|
886
|
+
name String
|
|
887
|
+
email String
|
|
888
|
+
emailVerified DateTime?
|
|
889
|
+
image String?
|
|
890
|
+
password String
|
|
891
|
+
isTwoFactorEnabled Boolean @default(false)
|
|
892
|
+
roleId String?
|
|
893
|
+
role Role? @relation(fields: [roleId], references: [id])
|
|
894
|
+
tenantId String
|
|
895
|
+
accounts Account[]
|
|
896
|
+
follows Follower[]
|
|
897
|
+
NotificationToUser NotificationToUser[]
|
|
898
|
+
Panel Panel[]
|
|
899
|
+
twoFactorConfirmation TwoFactorConfirmation?
|
|
900
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
901
|
+
supportConversationsAsCustomer SupportConversation[] @relation("SupportConversationCustomer")
|
|
902
|
+
supportConversationsAsAssignee SupportConversation[] @relation("SupportConversationAssignee")
|
|
903
|
+
supportMessagesSent SupportMessage[] @relation("SupportMessageSender")
|
|
831
904
|
|
|
832
905
|
@@unique([tenantId, email])
|
|
833
906
|
@@map("user")
|
|
@@ -1174,3 +1247,62 @@ model OperatorAvailabilityCache {
|
|
|
1174
1247
|
@@index([shiftId, date])
|
|
1175
1248
|
@@map("operator_availability_cache")
|
|
1176
1249
|
}
|
|
1250
|
+
|
|
1251
|
+
// chat
|
|
1252
|
+
|
|
1253
|
+
enum SupportConversationStatus {
|
|
1254
|
+
OPEN
|
|
1255
|
+
CLOSED
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
enum SupportMessageSenderType {
|
|
1259
|
+
USER
|
|
1260
|
+
SUPPORT
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
model SupportConversation {
|
|
1264
|
+
id String @id @default(uuid())
|
|
1265
|
+
tenantId String
|
|
1266
|
+
userId String
|
|
1267
|
+
assignedSupportUserId String?
|
|
1268
|
+
status SupportConversationStatus @default(OPEN)
|
|
1269
|
+
lastMessageAt DateTime @default(now())
|
|
1270
|
+
lastMessagePreview String? @db.VarChar(180)
|
|
1271
|
+
unreadForUserCount Int @default(0)
|
|
1272
|
+
unreadForSupportCount Int @default(0)
|
|
1273
|
+
createdAt DateTime @default(now())
|
|
1274
|
+
updatedAt DateTime @updatedAt
|
|
1275
|
+
|
|
1276
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1277
|
+
user User @relation("SupportConversationCustomer", fields: [userId], references: [id], onDelete: Cascade)
|
|
1278
|
+
assignedSupportUser User? @relation("SupportConversationAssignee", fields: [assignedSupportUserId], references: [id], onDelete: SetNull)
|
|
1279
|
+
messages SupportMessage[]
|
|
1280
|
+
|
|
1281
|
+
@@unique([tenantId, userId])
|
|
1282
|
+
@@index([tenantId, status, lastMessageAt])
|
|
1283
|
+
@@index([tenantId, unreadForSupportCount, lastMessageAt])
|
|
1284
|
+
@@map("support_conversation")
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
model SupportMessage {
|
|
1288
|
+
id String @id @default(uuid())
|
|
1289
|
+
conversationId String
|
|
1290
|
+
tenantId String
|
|
1291
|
+
senderType SupportMessageSenderType
|
|
1292
|
+
senderUserId String?
|
|
1293
|
+
body String? @db.Text
|
|
1294
|
+
attachmentUrl String? @db.Text
|
|
1295
|
+
attachmentName String? @db.VarChar(255)
|
|
1296
|
+
attachmentMimeType String? @db.VarChar(120)
|
|
1297
|
+
attachmentSize Int?
|
|
1298
|
+
readAt DateTime?
|
|
1299
|
+
createdAt DateTime @default(now())
|
|
1300
|
+
|
|
1301
|
+
conversation SupportConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
1302
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1303
|
+
senderUser User? @relation("SupportMessageSender", fields: [senderUserId], references: [id], onDelete: SetNull)
|
|
1304
|
+
|
|
1305
|
+
@@index([conversationId, createdAt])
|
|
1306
|
+
@@index([tenantId, createdAt])
|
|
1307
|
+
@@map("support_message")
|
|
1308
|
+
}
|