@juliobrim/prisma-shared 1.0.56 → 1.0.57
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,68 @@
|
|
|
1
|
+
-- CreateEnum
|
|
2
|
+
CREATE TYPE "SupportDiscordMessageDirection" AS ENUM ('TO_DISCORD', 'FROM_DISCORD');
|
|
3
|
+
|
|
4
|
+
-- CreateTable
|
|
5
|
+
CREATE TABLE "support_discord_conversation" (
|
|
6
|
+
"id" TEXT NOT NULL,
|
|
7
|
+
"tenantId" TEXT NOT NULL,
|
|
8
|
+
"conversationId" TEXT NOT NULL,
|
|
9
|
+
"discordGuildId" TEXT NOT NULL,
|
|
10
|
+
"discordCategoryId" TEXT,
|
|
11
|
+
"discordChannelId" TEXT NOT NULL,
|
|
12
|
+
"discordChannelName" VARCHAR(100) NOT NULL,
|
|
13
|
+
"channelTopic" VARCHAR(1024),
|
|
14
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
15
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
16
|
+
|
|
17
|
+
CONSTRAINT "support_discord_conversation_pkey" PRIMARY KEY ("id")
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- CreateTable
|
|
21
|
+
CREATE TABLE "support_discord_message" (
|
|
22
|
+
"id" TEXT NOT NULL,
|
|
23
|
+
"tenantId" TEXT NOT NULL,
|
|
24
|
+
"conversationId" TEXT NOT NULL,
|
|
25
|
+
"supportMessageId" TEXT NOT NULL,
|
|
26
|
+
"discordChannelId" TEXT NOT NULL,
|
|
27
|
+
"discordMessageId" TEXT NOT NULL,
|
|
28
|
+
"direction" "SupportDiscordMessageDirection" NOT NULL,
|
|
29
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
30
|
+
|
|
31
|
+
CONSTRAINT "support_discord_message_pkey" PRIMARY KEY ("id")
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
-- CreateIndex
|
|
35
|
+
CREATE UNIQUE INDEX "support_discord_conversation_conversationId_key" ON "support_discord_conversation"("conversationId");
|
|
36
|
+
|
|
37
|
+
-- CreateIndex
|
|
38
|
+
CREATE UNIQUE INDEX "support_discord_conversation_discordChannelId_key" ON "support_discord_conversation"("discordChannelId");
|
|
39
|
+
|
|
40
|
+
-- CreateIndex
|
|
41
|
+
CREATE INDEX "support_discord_conversation_tenantId_createdAt_idx" ON "support_discord_conversation"("tenantId", "createdAt");
|
|
42
|
+
|
|
43
|
+
-- CreateIndex
|
|
44
|
+
CREATE UNIQUE INDEX "support_discord_message_supportMessageId_key" ON "support_discord_message"("supportMessageId");
|
|
45
|
+
|
|
46
|
+
-- CreateIndex
|
|
47
|
+
CREATE UNIQUE INDEX "support_discord_message_discordMessageId_key" ON "support_discord_message"("discordMessageId");
|
|
48
|
+
|
|
49
|
+
-- CreateIndex
|
|
50
|
+
CREATE INDEX "support_discord_message_tenantId_conversationId_direction_idx" ON "support_discord_message"("tenantId", "conversationId", "direction");
|
|
51
|
+
|
|
52
|
+
-- AddForeignKey
|
|
53
|
+
ALTER TABLE "support_discord_conversation" ADD CONSTRAINT "support_discord_conversation_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
54
|
+
|
|
55
|
+
-- AddForeignKey
|
|
56
|
+
ALTER TABLE "support_discord_conversation" ADD CONSTRAINT "support_discord_conversation_conversationId_fkey" FOREIGN KEY ("conversationId") REFERENCES "support_conversation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
57
|
+
|
|
58
|
+
-- AddForeignKey
|
|
59
|
+
ALTER TABLE "support_discord_message" ADD CONSTRAINT "support_discord_message_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
60
|
+
|
|
61
|
+
-- AddForeignKey
|
|
62
|
+
ALTER TABLE "support_discord_message" ADD CONSTRAINT "support_discord_message_conversationId_fkey" FOREIGN KEY ("conversationId") REFERENCES "support_conversation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
63
|
+
|
|
64
|
+
-- AddForeignKey
|
|
65
|
+
ALTER TABLE "support_discord_message" ADD CONSTRAINT "support_discord_message_supportMessageId_fkey" FOREIGN KEY ("supportMessageId") REFERENCES "support_message"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
66
|
+
|
|
67
|
+
-- AddForeignKey
|
|
68
|
+
ALTER TABLE "support_discord_message" ADD CONSTRAINT "support_discord_message_discordChannelId_fkey" FOREIGN KEY ("discordChannelId") REFERENCES "support_discord_conversation"("discordChannelId") ON DELETE CASCADE ON UPDATE CASCADE;
|
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -9,63 +9,65 @@ datasource db {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
model Tenant {
|
|
12
|
-
id
|
|
13
|
-
name
|
|
14
|
-
slug
|
|
15
|
-
domain
|
|
16
|
-
isActive
|
|
17
|
-
createdAt
|
|
18
|
-
updatedAt
|
|
19
|
-
accounts
|
|
20
|
-
breaks
|
|
21
|
-
devices
|
|
22
|
-
deviceOperators
|
|
23
|
-
downtimeEvents
|
|
24
|
-
downtimeReasons
|
|
25
|
-
edges
|
|
26
|
-
flows
|
|
27
|
-
followers
|
|
28
|
-
inputRegisters
|
|
29
|
-
IotMessageRegister
|
|
30
|
-
itemsHandlingRegisters
|
|
31
|
-
machines
|
|
32
|
-
machineSensors
|
|
33
|
-
nodes
|
|
34
|
-
nodeOperationQueue
|
|
35
|
-
notifications
|
|
36
|
-
notificationToUsers
|
|
37
|
-
operations
|
|
38
|
-
operationGroups
|
|
39
|
-
operationGroupMembers
|
|
40
|
-
operationRegisters
|
|
41
|
-
operationToOperations
|
|
42
|
-
operators
|
|
43
|
-
operatorRoles
|
|
44
|
-
panels
|
|
45
|
-
products
|
|
46
|
-
productBatches
|
|
47
|
-
productComponents
|
|
48
|
-
productToOperations
|
|
49
|
-
productionNodes
|
|
50
|
-
productionOrders
|
|
51
|
-
reports
|
|
52
|
-
resources
|
|
53
|
-
sectors
|
|
54
|
-
sewMachineRawData
|
|
55
|
-
shifts
|
|
56
|
-
shiftDays
|
|
57
|
-
systemPreferences
|
|
58
|
-
processingScripts
|
|
59
|
-
users
|
|
60
|
-
roles
|
|
61
|
-
machineOperationStitch
|
|
62
|
-
productivityIntervals
|
|
63
|
-
operatorAvailability
|
|
64
|
-
qualityRegisters
|
|
65
|
-
qualityIssues
|
|
66
|
-
supportConversations
|
|
67
|
-
supportMessages
|
|
68
|
-
oeeIntervalFacts
|
|
12
|
+
id String @id @default(cuid())
|
|
13
|
+
name String @unique
|
|
14
|
+
slug String @unique
|
|
15
|
+
domain String? @unique
|
|
16
|
+
isActive Boolean @default(true)
|
|
17
|
+
createdAt DateTime @default(now())
|
|
18
|
+
updatedAt DateTime @updatedAt
|
|
19
|
+
accounts Account[]
|
|
20
|
+
breaks Break[]
|
|
21
|
+
devices Device[]
|
|
22
|
+
deviceOperators DeviceOperator[]
|
|
23
|
+
downtimeEvents DowntimeEvent[]
|
|
24
|
+
downtimeReasons DowntimeReason[]
|
|
25
|
+
edges Edge[]
|
|
26
|
+
flows Flow[]
|
|
27
|
+
followers Follower[]
|
|
28
|
+
inputRegisters InputRegister[]
|
|
29
|
+
IotMessageRegister IotMessageRegister[]
|
|
30
|
+
itemsHandlingRegisters ItemsHandlingRegister[]
|
|
31
|
+
machines Machine[]
|
|
32
|
+
machineSensors MachineSensors[]
|
|
33
|
+
nodes Node[]
|
|
34
|
+
nodeOperationQueue NodeOperationQueue[]
|
|
35
|
+
notifications Notification[]
|
|
36
|
+
notificationToUsers NotificationToUser[]
|
|
37
|
+
operations Operation[]
|
|
38
|
+
operationGroups OperationGroup[]
|
|
39
|
+
operationGroupMembers OperationGroupMember[]
|
|
40
|
+
operationRegisters OperationRegister[]
|
|
41
|
+
operationToOperations OperationToOperation[]
|
|
42
|
+
operators Operator[]
|
|
43
|
+
operatorRoles OperatorRole[]
|
|
44
|
+
panels Panel[]
|
|
45
|
+
products Product[]
|
|
46
|
+
productBatches ProductBatch[]
|
|
47
|
+
productComponents ProductComponents[]
|
|
48
|
+
productToOperations ProductToOperation[]
|
|
49
|
+
productionNodes ProductionNode[]
|
|
50
|
+
productionOrders ProductionOrder[]
|
|
51
|
+
reports Report[]
|
|
52
|
+
resources Resource[]
|
|
53
|
+
sectors Sector[]
|
|
54
|
+
sewMachineRawData SewMachineRawData[]
|
|
55
|
+
shifts Shift[]
|
|
56
|
+
shiftDays ShiftDay[]
|
|
57
|
+
systemPreferences SystemPreferences[]
|
|
58
|
+
processingScripts ProcessingScript[]
|
|
59
|
+
users User[]
|
|
60
|
+
roles Role[]
|
|
61
|
+
machineOperationStitch MachineOperationStitch[]
|
|
62
|
+
productivityIntervals ProductivityIntervalCache[]
|
|
63
|
+
operatorAvailability OperatorAvailabilityCache[]
|
|
64
|
+
qualityRegisters QualityRegister[]
|
|
65
|
+
qualityIssues QualityIssue[]
|
|
66
|
+
supportConversations SupportConversation[]
|
|
67
|
+
supportMessages SupportMessage[]
|
|
68
|
+
oeeIntervalFacts OeeIntervalFact[]
|
|
69
|
+
supportDiscordConversations SupportDiscordConversation[]
|
|
70
|
+
supportDiscordMessages SupportDiscordMessage[]
|
|
69
71
|
|
|
70
72
|
@@map("tenant")
|
|
71
73
|
}
|
|
@@ -1116,10 +1118,11 @@ enum Colors {
|
|
|
1116
1118
|
}
|
|
1117
1119
|
|
|
1118
1120
|
model MachineOperationStitch {
|
|
1119
|
-
machineId
|
|
1120
|
-
operationId
|
|
1121
|
-
stitches
|
|
1122
|
-
tenantId
|
|
1121
|
+
machineId String
|
|
1122
|
+
operationId String
|
|
1123
|
+
stitches Int
|
|
1124
|
+
tenantId String
|
|
1125
|
+
calibratedAt DateTime @default(now())
|
|
1123
1126
|
|
|
1124
1127
|
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
1125
1128
|
operation Operation @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
@@ -1273,10 +1276,12 @@ model SupportConversation {
|
|
|
1273
1276
|
createdAt DateTime @default(now())
|
|
1274
1277
|
updatedAt DateTime @updatedAt
|
|
1275
1278
|
|
|
1276
|
-
tenant
|
|
1277
|
-
user
|
|
1278
|
-
assignedSupportUser
|
|
1279
|
-
messages
|
|
1279
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1280
|
+
user User @relation("SupportConversationCustomer", fields: [userId], references: [id], onDelete: Cascade)
|
|
1281
|
+
assignedSupportUser User? @relation("SupportConversationAssignee", fields: [assignedSupportUserId], references: [id], onDelete: SetNull)
|
|
1282
|
+
messages SupportMessage[]
|
|
1283
|
+
supportDiscordConversation SupportDiscordConversation?
|
|
1284
|
+
supportDiscordMessages SupportDiscordMessage[]
|
|
1280
1285
|
|
|
1281
1286
|
@@unique([tenantId, userId])
|
|
1282
1287
|
@@index([tenantId, status, lastMessageAt])
|
|
@@ -1298,11 +1303,56 @@ model SupportMessage {
|
|
|
1298
1303
|
readAt DateTime?
|
|
1299
1304
|
createdAt DateTime @default(now())
|
|
1300
1305
|
|
|
1301
|
-
conversation
|
|
1302
|
-
tenant
|
|
1303
|
-
senderUser
|
|
1306
|
+
conversation SupportConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
1307
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1308
|
+
senderUser User? @relation("SupportMessageSender", fields: [senderUserId], references: [id], onDelete: SetNull)
|
|
1309
|
+
supportDiscordMessage SupportDiscordMessage?
|
|
1304
1310
|
|
|
1305
1311
|
@@index([conversationId, createdAt])
|
|
1306
1312
|
@@index([tenantId, createdAt])
|
|
1307
1313
|
@@map("support_message")
|
|
1308
1314
|
}
|
|
1315
|
+
|
|
1316
|
+
enum SupportDiscordMessageDirection {
|
|
1317
|
+
TO_DISCORD
|
|
1318
|
+
FROM_DISCORD
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
model SupportDiscordConversation {
|
|
1322
|
+
id String @id @default(uuid())
|
|
1323
|
+
tenantId String
|
|
1324
|
+
conversationId String @unique
|
|
1325
|
+
discordGuildId String
|
|
1326
|
+
discordCategoryId String?
|
|
1327
|
+
discordChannelId String @unique
|
|
1328
|
+
discordChannelName String @db.VarChar(100)
|
|
1329
|
+
channelTopic String? @db.VarChar(1024)
|
|
1330
|
+
createdAt DateTime @default(now())
|
|
1331
|
+
updatedAt DateTime @updatedAt
|
|
1332
|
+
|
|
1333
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1334
|
+
conversation SupportConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
1335
|
+
messages SupportDiscordMessage[]
|
|
1336
|
+
|
|
1337
|
+
@@index([tenantId, createdAt])
|
|
1338
|
+
@@map("support_discord_conversation")
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
model SupportDiscordMessage {
|
|
1342
|
+
id String @id @default(uuid())
|
|
1343
|
+
tenantId String
|
|
1344
|
+
conversationId String
|
|
1345
|
+
supportMessageId String @unique
|
|
1346
|
+
discordChannelId String
|
|
1347
|
+
discordMessageId String @unique
|
|
1348
|
+
direction SupportDiscordMessageDirection
|
|
1349
|
+
createdAt DateTime @default(now())
|
|
1350
|
+
|
|
1351
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1352
|
+
conversation SupportConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
1353
|
+
supportMessage SupportMessage @relation(fields: [supportMessageId], references: [id], onDelete: Cascade)
|
|
1354
|
+
discordConversation SupportDiscordConversation @relation(fields: [discordChannelId], references: [discordChannelId], onDelete: Cascade)
|
|
1355
|
+
|
|
1356
|
+
@@index([tenantId, conversationId, direction])
|
|
1357
|
+
@@map("support_discord_message")
|
|
1358
|
+
}
|