@juliobrim/prisma-shared 1.0.45 → 1.0.47

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,36 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the `user_shift` table. If the table is not empty, all the data it contains will be lost.
5
+
6
+ */
7
+ -- DropForeignKey
8
+ ALTER TABLE "user_shift" DROP CONSTRAINT "fk_shift";
9
+
10
+ -- DropForeignKey
11
+ ALTER TABLE "user_shift" DROP CONSTRAINT "user_shift_tenantId_fkey";
12
+
13
+ -- DropForeignKey
14
+ ALTER TABLE "user_shift" DROP CONSTRAINT "user_shift_user_id_fkey";
15
+
16
+ -- DropTable
17
+ DROP TABLE "user_shift";
18
+
19
+ -- CreateTable
20
+ CREATE TABLE "operator_shift" (
21
+ "id" SERIAL NOT NULL,
22
+ "operator_id" TEXT NOT NULL,
23
+ "shift_id" TEXT,
24
+ "tenantId" TEXT,
25
+
26
+ CONSTRAINT "operator_shift_pkey" PRIMARY KEY ("id")
27
+ );
28
+
29
+ -- AddForeignKey
30
+ ALTER TABLE "operator_shift" ADD CONSTRAINT "fk_shift" FOREIGN KEY ("shift_id") REFERENCES "shift"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
31
+
32
+ -- AddForeignKey
33
+ ALTER TABLE "operator_shift" ADD CONSTRAINT "operator_shift_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
34
+
35
+ -- AddForeignKey
36
+ ALTER TABLE "operator_shift" ADD CONSTRAINT "operator_shift_operator_id_fkey" FOREIGN KEY ("operator_id") REFERENCES "operator"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,5 @@
1
+ -- AlterTable
2
+ ALTER TABLE "productivity_interval_cache" ADD COLUMN "productionOrderId" TEXT;
3
+
4
+ -- AddForeignKey
5
+ ALTER TABLE "productivity_interval_cache" ADD CONSTRAINT "productivity_interval_cache_productionOrderId_fkey" FOREIGN KEY ("productionOrderId") REFERENCES "production_order"("id") ON DELETE CASCADE ON UPDATE CASCADE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juliobrim/prisma-shared",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "description": "Schema Prisma compartilhado entre projetos Sabcon",
5
5
  "main": "schema.prisma",
6
6
  "files": [
package/schema.prisma CHANGED
@@ -59,7 +59,7 @@ model Tenant {
59
59
  processingScripts ProcessingScript[]
60
60
  users User[]
61
61
  userPermissions UserPermission[]
62
- userShifts UserShift[]
62
+ operatorShifts OperatorShift[]
63
63
  machineOperationStitch MachineOperationStitch[]
64
64
  productivityIntervals ProductivityIntervalCache[]
65
65
  aiConversations AiConversation[]
@@ -537,6 +537,7 @@ model Operator {
537
537
  habilityResources Resource[] @relation("OperatorToResource")
538
538
  shifts Shift[] @relation("OperatorToShift")
539
539
  productivityIntervals ProductivityIntervalCache[]
540
+ operatorShifts OperatorShift[]
540
541
 
541
542
  @@index([tenantId, isDeleted])
542
543
  @@map("operator")
@@ -648,26 +649,27 @@ model ProductionNode {
648
649
  }
649
650
 
650
651
  model ProductionOrder {
651
- id String @id @default(cuid())
652
+ id String @id @default(cuid())
652
653
  productId String
653
654
  flowId String?
654
- productionOrderIndex Int? @unique
655
+ productionOrderIndex Int? @unique
655
656
  batchSize Float
656
- hasStarted Boolean @default(false)
657
- isRunning Boolean @default(false)
658
- isFinished Boolean @default(false)
657
+ hasStarted Boolean @default(false)
658
+ isRunning Boolean @default(false)
659
+ isFinished Boolean @default(false)
659
660
  tenantId String?
660
- endDate DateTime? @db.Date
661
- expectedEndDate DateTime? @db.Date
662
- startDate DateTime? @db.Date
661
+ endDate DateTime? @db.Date
662
+ expectedEndDate DateTime? @db.Date
663
+ startDate DateTime? @db.Date
663
664
  inputRegisters InputRegister[]
664
665
  ItemsHandlingRegister ItemsHandlingRegister[]
665
666
  NodeOperationQueue NodeOperationQueue[]
666
667
  operationRegisters OperationRegister[]
667
668
  productionNode ProductionNode[]
668
- flow Flow? @relation(fields: [flowId], references: [id])
669
- Product Product @relation(fields: [productId], references: [id])
670
- tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
669
+ productivityIntervals ProductivityIntervalCache[]
670
+ flow Flow? @relation(fields: [flowId], references: [id])
671
+ Product Product @relation(fields: [productId], references: [id])
672
+ tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
671
673
 
672
674
  @@index([tenantId, isFinished])
673
675
  @@index([productId])
@@ -745,15 +747,15 @@ model SewMachineRawData {
745
747
  }
746
748
 
747
749
  model Shift {
748
- id String @id @default(cuid())
749
- name String @unique @db.VarChar(100)
750
- start_time DateTime @db.Time(6)
751
- end_time DateTime @db.Time(6)
752
- tenantId String?
753
- breaks Break[]
754
- tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
755
- user_shift UserShift[]
756
- operators Operator[] @relation("OperatorToShift")
750
+ id String @id @default(cuid())
751
+ name String @unique @db.VarChar(100)
752
+ start_time DateTime @db.Time(6)
753
+ end_time DateTime @db.Time(6)
754
+ tenantId String?
755
+ breaks Break[]
756
+ tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
757
+ operator_shift OperatorShift[]
758
+ operators Operator[] @relation("OperatorToShift")
757
759
 
758
760
  @@map("shift")
759
761
  }
@@ -808,7 +810,6 @@ model User {
808
810
  twoFactorConfirmation TwoFactorConfirmation?
809
811
  tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
810
812
  userPermissions UserPermission[]
811
- UserShift UserShift[]
812
813
  aiConversations AiConversation[]
813
814
 
814
815
  @@map("user")
@@ -826,16 +827,16 @@ model UserPermission {
826
827
  @@map("user_permission")
827
828
  }
828
829
 
829
- model UserShift {
830
- id Int @id @default(autoincrement())
831
- userId String @map("user_id")
832
- shift_id String?
833
- tenantId String?
834
- shift Shift? @relation(fields: [shift_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_shift")
835
- tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
836
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
830
+ model OperatorShift {
831
+ id Int @id @default(autoincrement())
832
+ operatorId String @map("operator_id")
833
+ shift_id String?
834
+ tenantId String?
835
+ shift Shift? @relation(fields: [shift_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_shift")
836
+ tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
837
+ operator Operator @relation(fields: [operatorId], references: [id], onDelete: Cascade)
837
838
 
838
- @@map("user_shift")
839
+ @@map("operator_shift")
839
840
  }
840
841
 
841
842
  view ProductivityInterval {
@@ -1048,11 +1049,13 @@ model MachineOperationStitch {
1048
1049
  }
1049
1050
 
1050
1051
  model ProductivityIntervalCache {
1051
- id String @id @default(cuid())
1052
- tenantId String?
1053
- machineId String
1054
- operatorId String
1055
- operationId String?
1052
+ id String @id @default(cuid())
1053
+ tenantId String?
1054
+ machineId String
1055
+ operatorId String
1056
+ operationId String?
1057
+ productionOrderId String?
1058
+
1056
1059
  sequenceId Int @map("sequence_id")
1057
1060
  groupStartTimestamp DateTime @map("group_start_timestamp")
1058
1061
  groupEndTimestamp DateTime @map("group_end_timestamp")
@@ -1067,10 +1070,11 @@ model ProductivityIntervalCache {
1067
1070
 
1068
1071
  createdAt DateTime @default(now())
1069
1072
 
1070
- tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1071
- machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
1072
- operator Operator @relation(fields: [operatorId], references: [id], onDelete: Cascade)
1073
- operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
1073
+ tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1074
+ machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
1075
+ operator Operator @relation(fields: [operatorId], references: [id], onDelete: Cascade)
1076
+ operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
1077
+ productionOrder ProductionOrder? @relation(fields: [productionOrderId], references: [id], onDelete: Cascade)
1074
1078
 
1075
1079
  @@unique([machineId, groupStartTimestamp])
1076
1080
  @@index([tenantId, machineId, groupStartTimestamp])