@juliobrim/prisma-shared 1.0.53 → 1.0.55
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,22 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "MachineOperationalState" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"machineId" TEXT NOT NULL,
|
|
5
|
+
"countState" JSONB,
|
|
6
|
+
"lastMachineTimestamp" TIMESTAMP(3),
|
|
7
|
+
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
8
|
+
|
|
9
|
+
CONSTRAINT "MachineOperationalState_pkey" PRIMARY KEY ("id")
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
-- CreateIndex
|
|
13
|
+
CREATE UNIQUE INDEX "MachineOperationalState_machineId_key" ON "MachineOperationalState"("machineId");
|
|
14
|
+
|
|
15
|
+
-- CreateIndex
|
|
16
|
+
CREATE INDEX "MachineOperationalState_machineId_idx" ON "MachineOperationalState"("machineId");
|
|
17
|
+
|
|
18
|
+
-- CreateIndex
|
|
19
|
+
CREATE INDEX "MachineOperationalState_lastMachineTimestamp_idx" ON "MachineOperationalState"("lastMachineTimestamp");
|
|
20
|
+
|
|
21
|
+
-- AddForeignKey
|
|
22
|
+
ALTER TABLE "MachineOperationalState" ADD CONSTRAINT "MachineOperationalState_machineId_fkey" FOREIGN KEY ("machineId") REFERENCES "machine"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -63,6 +63,8 @@ model Tenant {
|
|
|
63
63
|
operatorAvailability OperatorAvailabilityCache[]
|
|
64
64
|
qualityRegisters QualityRegister[]
|
|
65
65
|
qualityIssues QualityIssue[]
|
|
66
|
+
supportConversations SupportConversation[]
|
|
67
|
+
supportMessages SupportMessage[]
|
|
66
68
|
|
|
67
69
|
@@map("tenant")
|
|
68
70
|
}
|
|
@@ -284,6 +286,7 @@ model Machine {
|
|
|
284
286
|
MachineScriptState MachineScriptState?
|
|
285
287
|
machineOperationStitch MachineOperationStitch[]
|
|
286
288
|
productivityIntervals ProductivityIntervalCache[]
|
|
289
|
+
machineOperationalState MachineOperationalState?
|
|
287
290
|
|
|
288
291
|
@@unique([tenantId, name])
|
|
289
292
|
@@index([sectorId])
|
|
@@ -811,22 +814,25 @@ model TwoFactorToken {
|
|
|
811
814
|
}
|
|
812
815
|
|
|
813
816
|
model User {
|
|
814
|
-
id
|
|
815
|
-
name
|
|
816
|
-
email
|
|
817
|
-
emailVerified
|
|
818
|
-
image
|
|
819
|
-
password
|
|
820
|
-
isTwoFactorEnabled
|
|
821
|
-
roleId
|
|
822
|
-
role
|
|
823
|
-
tenantId
|
|
824
|
-
accounts
|
|
825
|
-
follows
|
|
826
|
-
NotificationToUser
|
|
827
|
-
Panel
|
|
828
|
-
twoFactorConfirmation
|
|
829
|
-
tenant
|
|
817
|
+
id String @id @default(uuid())
|
|
818
|
+
name String
|
|
819
|
+
email String
|
|
820
|
+
emailVerified DateTime?
|
|
821
|
+
image String?
|
|
822
|
+
password String
|
|
823
|
+
isTwoFactorEnabled Boolean @default(false)
|
|
824
|
+
roleId String?
|
|
825
|
+
role Role? @relation(fields: [roleId], references: [id])
|
|
826
|
+
tenantId String
|
|
827
|
+
accounts Account[]
|
|
828
|
+
follows Follower[]
|
|
829
|
+
NotificationToUser NotificationToUser[]
|
|
830
|
+
Panel Panel[]
|
|
831
|
+
twoFactorConfirmation TwoFactorConfirmation?
|
|
832
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
833
|
+
supportConversationsAsCustomer SupportConversation[] @relation("SupportConversationCustomer")
|
|
834
|
+
supportConversationsAsAssignee SupportConversation[] @relation("SupportConversationAssignee")
|
|
835
|
+
supportMessagesSent SupportMessage[] @relation("SupportMessageSender")
|
|
830
836
|
|
|
831
837
|
@@unique([tenantId, email])
|
|
832
838
|
@@map("user")
|
|
@@ -909,6 +915,20 @@ model Device {
|
|
|
909
915
|
@@map("device")
|
|
910
916
|
}
|
|
911
917
|
|
|
918
|
+
model MachineOperationalState {
|
|
919
|
+
id String @id @default(cuid())
|
|
920
|
+
machineId String @unique
|
|
921
|
+
countState Json?
|
|
922
|
+
lastMachineTimestamp DateTime?
|
|
923
|
+
updatedAt DateTime @default(now()) @updatedAt
|
|
924
|
+
|
|
925
|
+
machine Machine? @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
926
|
+
|
|
927
|
+
@@index([machineId])
|
|
928
|
+
@@index([lastMachineTimestamp])
|
|
929
|
+
@@map("MachineOperationalState")
|
|
930
|
+
}
|
|
931
|
+
|
|
912
932
|
model MachineSensors {
|
|
913
933
|
id String @id @default(cuid())
|
|
914
934
|
machineId String @unique
|
|
@@ -1159,3 +1179,62 @@ model OperatorAvailabilityCache {
|
|
|
1159
1179
|
@@index([shiftId, date])
|
|
1160
1180
|
@@map("operator_availability_cache")
|
|
1161
1181
|
}
|
|
1182
|
+
|
|
1183
|
+
// chat
|
|
1184
|
+
|
|
1185
|
+
enum SupportConversationStatus {
|
|
1186
|
+
OPEN
|
|
1187
|
+
CLOSED
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
enum SupportMessageSenderType {
|
|
1191
|
+
USER
|
|
1192
|
+
SUPPORT
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
model SupportConversation {
|
|
1196
|
+
id String @id @default(uuid())
|
|
1197
|
+
tenantId String
|
|
1198
|
+
userId String
|
|
1199
|
+
assignedSupportUserId String?
|
|
1200
|
+
status SupportConversationStatus @default(OPEN)
|
|
1201
|
+
lastMessageAt DateTime @default(now())
|
|
1202
|
+
lastMessagePreview String? @db.VarChar(180)
|
|
1203
|
+
unreadForUserCount Int @default(0)
|
|
1204
|
+
unreadForSupportCount Int @default(0)
|
|
1205
|
+
createdAt DateTime @default(now())
|
|
1206
|
+
updatedAt DateTime @updatedAt
|
|
1207
|
+
|
|
1208
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1209
|
+
user User @relation("SupportConversationCustomer", fields: [userId], references: [id], onDelete: Cascade)
|
|
1210
|
+
assignedSupportUser User? @relation("SupportConversationAssignee", fields: [assignedSupportUserId], references: [id], onDelete: SetNull)
|
|
1211
|
+
messages SupportMessage[]
|
|
1212
|
+
|
|
1213
|
+
@@unique([tenantId, userId])
|
|
1214
|
+
@@index([tenantId, status, lastMessageAt])
|
|
1215
|
+
@@index([tenantId, unreadForSupportCount, lastMessageAt])
|
|
1216
|
+
@@map("support_conversation")
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
model SupportMessage {
|
|
1220
|
+
id String @id @default(uuid())
|
|
1221
|
+
conversationId String
|
|
1222
|
+
tenantId String
|
|
1223
|
+
senderType SupportMessageSenderType
|
|
1224
|
+
senderUserId String?
|
|
1225
|
+
body String? @db.Text
|
|
1226
|
+
attachmentUrl String? @db.Text
|
|
1227
|
+
attachmentName String? @db.VarChar(255)
|
|
1228
|
+
attachmentMimeType String? @db.VarChar(120)
|
|
1229
|
+
attachmentSize Int?
|
|
1230
|
+
readAt DateTime?
|
|
1231
|
+
createdAt DateTime @default(now())
|
|
1232
|
+
|
|
1233
|
+
conversation SupportConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
1234
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1235
|
+
senderUser User? @relation("SupportMessageSender", fields: [senderUserId], references: [id], onDelete: SetNull)
|
|
1236
|
+
|
|
1237
|
+
@@index([conversationId, createdAt])
|
|
1238
|
+
@@index([tenantId, createdAt])
|
|
1239
|
+
@@map("support_message")
|
|
1240
|
+
}
|