@juliobrim/prisma-shared 1.0.55 → 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,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;
@@ -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;
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "machine_operation_stitch" ADD COLUMN "calibratedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juliobrim/prisma-shared",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
4
4
  "description": "Schema Prisma compartilhado entre projetos Sabcon",
5
5
  "main": "schema.prisma",
6
6
  "files": [
package/schema.prisma CHANGED
@@ -9,62 +9,65 @@ datasource db {
9
9
  }
10
10
 
11
11
  model Tenant {
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[]
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[]
68
71
 
69
72
  @@map("tenant")
70
73
  }
@@ -287,6 +290,7 @@ model Machine {
287
290
  machineOperationStitch MachineOperationStitch[]
288
291
  productivityIntervals ProductivityIntervalCache[]
289
292
  machineOperationalState MachineOperationalState?
293
+ oeeIntervalFacts OeeIntervalFact[]
290
294
 
291
295
  @@unique([tenantId, name])
292
296
  @@index([sectorId])
@@ -362,6 +366,66 @@ model NotificationToUser {
362
366
  @@map("notification_to_user")
363
367
  }
364
368
 
369
+ model OeeIntervalFact {
370
+ id String @id @default(cuid())
371
+ tenantId String
372
+ machineId String
373
+ operatorId String?
374
+ operationId String?
375
+ operationGroupId Int?
376
+ productionOrderId String?
377
+ productId String?
378
+ shiftId String?
379
+
380
+ date DateTime @db.Date
381
+ windowStart DateTime @db.Timestamp(6)
382
+ windowEnd DateTime @db.Timestamp(6)
383
+
384
+ sourceType StatisticsSourceType
385
+ calculationVersion Int @default(1)
386
+ generatedAt DateTime @default(now())
387
+
388
+ plannedSeconds Float @default(0)
389
+ breakSeconds Float @default(0)
390
+ grossSpanSeconds Float @default(0)
391
+ runtimeSeconds Float @default(0)
392
+ impactfulDowntimeSeconds Float @default(0)
393
+ nonImpactfulDowntimeSeconds Float @default(0)
394
+ unjustifiedDowntimeSeconds Float @default(0)
395
+
396
+ producedQty Int @default(0)
397
+ rejectedQty Int @default(0)
398
+ goodQty Int @default(0)
399
+ idealCycleTimeSeconds Float @default(0)
400
+
401
+ performance Float @default(0)
402
+ availability Float @default(0)
403
+ quality Float @default(0)
404
+ oee Float @default(0)
405
+
406
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
407
+ machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
408
+ operator Operator? @relation(fields: [operatorId], references: [id], onDelete: Cascade)
409
+ operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
410
+ operationGroup OperationGroup? @relation(fields: [operationGroupId], references: [id], onDelete: Cascade)
411
+ productionOrder ProductionOrder? @relation(fields: [productionOrderId], references: [id], onDelete: Cascade)
412
+ product Product? @relation(fields: [productId], references: [id], onDelete: Cascade)
413
+ shift Shift? @relation(fields: [shiftId], references: [id], onDelete: SetNull)
414
+
415
+ @@index([tenantId, date])
416
+ @@index([tenantId, machineId, windowStart])
417
+ @@index([tenantId, operatorId, windowStart])
418
+ @@index([tenantId, operationId, windowStart])
419
+ @@index([tenantId, productionOrderId, windowStart])
420
+ @@index([tenantId, sourceType, windowStart])
421
+ @@map("oee_interval_fact")
422
+ }
423
+
424
+ enum StatisticsSourceType {
425
+ CLOSED
426
+ DYNAMIC
427
+ }
428
+
365
429
  model Operation {
366
430
  id String @id @default(cuid())
367
431
  stitches Int
@@ -397,6 +461,7 @@ model Operation {
397
461
  machineOperationStitch MachineOperationStitch[]
398
462
  productivityIntervals ProductivityIntervalCache[]
399
463
  qualityRegisters QualityRegister[]
464
+ oeeIntervalFacts OeeIntervalFact[]
400
465
 
401
466
  @@index([nodeId], map: "idx_operation_node_id")
402
467
  @@map("operation")
@@ -418,6 +483,7 @@ model OperationGroup {
418
483
  operationRegisters OperationRegister[]
419
484
  productionNodes ProductionNode[]
420
485
  operations Operation[] @relation("OperationToOperationGroup")
486
+ oeeIntervalFacts OeeIntervalFact[]
421
487
 
422
488
  @@map("operation_group")
423
489
  }
@@ -511,6 +577,7 @@ model Operator {
511
577
  productivityIntervals ProductivityIntervalCache[]
512
578
  operatorAvailability OperatorAvailabilityCache[]
513
579
  qualityRegisters QualityRegister[]
580
+ oeeIntervalFacts OeeIntervalFact[]
514
581
 
515
582
  @@unique([tenantId, name])
516
583
  @@index([tenantId, isDeleted])
@@ -583,6 +650,7 @@ model Product {
583
650
  componentOf ProductComponents[] @relation("composedBy")
584
651
  operations ProductToOperation[]
585
652
  productionOrders ProductionOrder[]
653
+ oeeIntervalFacts OeeIntervalFact[]
586
654
 
587
655
  @@index([tenantId])
588
656
  @@index([isDeleted])
@@ -648,6 +716,7 @@ model ProductionOrder {
648
716
  flow Flow? @relation(fields: [flowId], references: [id])
649
717
  Product Product @relation(fields: [productId], references: [id])
650
718
  tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
719
+ oeeIntervalFacts OeeIntervalFact[]
651
720
 
652
721
  @@unique([tenantId, productionOrderIndex])
653
722
  @@index([tenantId, isFinished])
@@ -759,6 +828,7 @@ model Shift {
759
828
  tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
760
829
  operators Operator[]
761
830
  operatorAvailability OperatorAvailabilityCache[]
831
+ oeeIntervalFacts OeeIntervalFact[]
762
832
 
763
833
  @@unique([tenantId, name])
764
834
  @@map("shift")
@@ -1048,10 +1118,11 @@ enum Colors {
1048
1118
  }
1049
1119
 
1050
1120
  model MachineOperationStitch {
1051
- machineId String
1052
- operationId String
1053
- stitches Int
1054
- tenantId String
1121
+ machineId String
1122
+ operationId String
1123
+ stitches Int
1124
+ tenantId String
1125
+ calibratedAt DateTime @default(now())
1055
1126
 
1056
1127
  machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
1057
1128
  operation Operation @relation(fields: [operationId], references: [id], onDelete: Cascade)
@@ -1205,10 +1276,12 @@ model SupportConversation {
1205
1276
  createdAt DateTime @default(now())
1206
1277
  updatedAt DateTime @updatedAt
1207
1278
 
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[]
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[]
1212
1285
 
1213
1286
  @@unique([tenantId, userId])
1214
1287
  @@index([tenantId, status, lastMessageAt])
@@ -1230,11 +1303,56 @@ model SupportMessage {
1230
1303
  readAt DateTime?
1231
1304
  createdAt DateTime @default(now())
1232
1305
 
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)
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?
1236
1310
 
1237
1311
  @@index([conversationId, createdAt])
1238
1312
  @@index([tenantId, createdAt])
1239
1313
  @@map("support_message")
1240
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
+ }