@juliobrim/prisma-shared 1.0.55 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juliobrim/prisma-shared",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
4
4
  "description": "Schema Prisma compartilhado entre projetos Sabcon",
5
5
  "main": "schema.prisma",
6
6
  "files": [
package/schema.prisma CHANGED
@@ -65,6 +65,7 @@ model Tenant {
65
65
  qualityIssues QualityIssue[]
66
66
  supportConversations SupportConversation[]
67
67
  supportMessages SupportMessage[]
68
+ oeeIntervalFacts OeeIntervalFact[]
68
69
 
69
70
  @@map("tenant")
70
71
  }
@@ -287,6 +288,7 @@ model Machine {
287
288
  machineOperationStitch MachineOperationStitch[]
288
289
  productivityIntervals ProductivityIntervalCache[]
289
290
  machineOperationalState MachineOperationalState?
291
+ oeeIntervalFacts OeeIntervalFact[]
290
292
 
291
293
  @@unique([tenantId, name])
292
294
  @@index([sectorId])
@@ -362,6 +364,66 @@ model NotificationToUser {
362
364
  @@map("notification_to_user")
363
365
  }
364
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
+
365
427
  model Operation {
366
428
  id String @id @default(cuid())
367
429
  stitches Int
@@ -397,6 +459,7 @@ model Operation {
397
459
  machineOperationStitch MachineOperationStitch[]
398
460
  productivityIntervals ProductivityIntervalCache[]
399
461
  qualityRegisters QualityRegister[]
462
+ oeeIntervalFacts OeeIntervalFact[]
400
463
 
401
464
  @@index([nodeId], map: "idx_operation_node_id")
402
465
  @@map("operation")
@@ -418,6 +481,7 @@ model OperationGroup {
418
481
  operationRegisters OperationRegister[]
419
482
  productionNodes ProductionNode[]
420
483
  operations Operation[] @relation("OperationToOperationGroup")
484
+ oeeIntervalFacts OeeIntervalFact[]
421
485
 
422
486
  @@map("operation_group")
423
487
  }
@@ -511,6 +575,7 @@ model Operator {
511
575
  productivityIntervals ProductivityIntervalCache[]
512
576
  operatorAvailability OperatorAvailabilityCache[]
513
577
  qualityRegisters QualityRegister[]
578
+ oeeIntervalFacts OeeIntervalFact[]
514
579
 
515
580
  @@unique([tenantId, name])
516
581
  @@index([tenantId, isDeleted])
@@ -583,6 +648,7 @@ model Product {
583
648
  componentOf ProductComponents[] @relation("composedBy")
584
649
  operations ProductToOperation[]
585
650
  productionOrders ProductionOrder[]
651
+ oeeIntervalFacts OeeIntervalFact[]
586
652
 
587
653
  @@index([tenantId])
588
654
  @@index([isDeleted])
@@ -648,6 +714,7 @@ model ProductionOrder {
648
714
  flow Flow? @relation(fields: [flowId], references: [id])
649
715
  Product Product @relation(fields: [productId], references: [id])
650
716
  tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
717
+ oeeIntervalFacts OeeIntervalFact[]
651
718
 
652
719
  @@unique([tenantId, productionOrderIndex])
653
720
  @@index([tenantId, isFinished])
@@ -759,6 +826,7 @@ model Shift {
759
826
  tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
760
827
  operators Operator[]
761
828
  operatorAvailability OperatorAvailabilityCache[]
829
+ oeeIntervalFacts OeeIntervalFact[]
762
830
 
763
831
  @@unique([tenantId, name])
764
832
  @@map("shift")