@juliobrim/prisma-shared 1.0.47 → 1.0.49
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,69 @@
|
|
|
1
|
+
-- CreateEnum
|
|
2
|
+
CREATE TYPE "QualityIssueCategory" AS ENUM ('HUMAN_ERROR', 'RAW_MATERIAL', 'MACHINE_FAILURE', 'PROCESS_DEVIATION', 'OTHER');
|
|
3
|
+
|
|
4
|
+
-- CreateTable
|
|
5
|
+
CREATE TABLE "quality_register" (
|
|
6
|
+
"id" TEXT NOT NULL,
|
|
7
|
+
"timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
8
|
+
"operationId" TEXT NOT NULL,
|
|
9
|
+
"productionOrderId" TEXT,
|
|
10
|
+
"operatorId" TEXT,
|
|
11
|
+
"sectorId" TEXT,
|
|
12
|
+
"qualityIssueId" TEXT,
|
|
13
|
+
"amount" INTEGER NOT NULL DEFAULT 1,
|
|
14
|
+
"comments" TEXT,
|
|
15
|
+
"tenantId" TEXT,
|
|
16
|
+
|
|
17
|
+
CONSTRAINT "quality_register_pkey" PRIMARY KEY ("id")
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- CreateTable
|
|
21
|
+
CREATE TABLE "quality_issue" (
|
|
22
|
+
"id" TEXT NOT NULL,
|
|
23
|
+
"name" TEXT NOT NULL,
|
|
24
|
+
"description" TEXT,
|
|
25
|
+
"category" "QualityIssueCategory" NOT NULL DEFAULT 'OTHER',
|
|
26
|
+
"isDeleted" BOOLEAN NOT NULL DEFAULT false,
|
|
27
|
+
"tenantId" TEXT,
|
|
28
|
+
|
|
29
|
+
CONSTRAINT "quality_issue_pkey" PRIMARY KEY ("id")
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
-- CreateIndex
|
|
33
|
+
CREATE INDEX "quality_register_tenantId_idx" ON "quality_register"("tenantId");
|
|
34
|
+
|
|
35
|
+
-- CreateIndex
|
|
36
|
+
CREATE INDEX "quality_register_operationId_idx" ON "quality_register"("operationId");
|
|
37
|
+
|
|
38
|
+
-- CreateIndex
|
|
39
|
+
CREATE INDEX "quality_register_productionOrderId_idx" ON "quality_register"("productionOrderId");
|
|
40
|
+
|
|
41
|
+
-- CreateIndex
|
|
42
|
+
CREATE INDEX "quality_register_operatorId_idx" ON "quality_register"("operatorId");
|
|
43
|
+
|
|
44
|
+
-- CreateIndex
|
|
45
|
+
CREATE INDEX "quality_register_timestamp_idx" ON "quality_register"("timestamp");
|
|
46
|
+
|
|
47
|
+
-- CreateIndex
|
|
48
|
+
CREATE INDEX "quality_issue_tenantId_idx" ON "quality_issue"("tenantId");
|
|
49
|
+
|
|
50
|
+
-- AddForeignKey
|
|
51
|
+
ALTER TABLE "quality_register" ADD CONSTRAINT "quality_register_operationId_fkey" FOREIGN KEY ("operationId") REFERENCES "operation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
52
|
+
|
|
53
|
+
-- AddForeignKey
|
|
54
|
+
ALTER TABLE "quality_register" ADD CONSTRAINT "quality_register_productionOrderId_fkey" FOREIGN KEY ("productionOrderId") REFERENCES "production_order"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
55
|
+
|
|
56
|
+
-- AddForeignKey
|
|
57
|
+
ALTER TABLE "quality_register" ADD CONSTRAINT "quality_register_operatorId_fkey" FOREIGN KEY ("operatorId") REFERENCES "operator"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
58
|
+
|
|
59
|
+
-- AddForeignKey
|
|
60
|
+
ALTER TABLE "quality_register" ADD CONSTRAINT "quality_register_sectorId_fkey" FOREIGN KEY ("sectorId") REFERENCES "sector"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
61
|
+
|
|
62
|
+
-- AddForeignKey
|
|
63
|
+
ALTER TABLE "quality_register" ADD CONSTRAINT "quality_register_qualityIssueId_fkey" FOREIGN KEY ("qualityIssueId") REFERENCES "quality_issue"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
64
|
+
|
|
65
|
+
-- AddForeignKey
|
|
66
|
+
ALTER TABLE "quality_register" ADD CONSTRAINT "quality_register_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
67
|
+
|
|
68
|
+
-- AddForeignKey
|
|
69
|
+
ALTER TABLE "quality_issue" ADD CONSTRAINT "quality_issue_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `shiftId` on the `break` table. All the data in the column will be lost.
|
|
5
|
+
- You are about to drop the column `end_time` on the `shift` table. All the data in the column will be lost.
|
|
6
|
+
- You are about to drop the column `start_time` on the `shift` table. All the data in the column will be lost.
|
|
7
|
+
- You are about to drop the `_OperatorToShift` table. If the table is not empty, all the data it contains will be lost.
|
|
8
|
+
- You are about to drop the `operator_shift` table. If the table is not empty, all the data it contains will be lost.
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
-- DropForeignKey
|
|
12
|
+
ALTER TABLE "_OperatorToShift" DROP CONSTRAINT "_OperatorToShift_A_fkey";
|
|
13
|
+
|
|
14
|
+
-- DropForeignKey
|
|
15
|
+
ALTER TABLE "_OperatorToShift" DROP CONSTRAINT "_OperatorToShift_B_fkey";
|
|
16
|
+
|
|
17
|
+
-- DropForeignKey
|
|
18
|
+
ALTER TABLE "break" DROP CONSTRAINT "break_shiftId_fkey";
|
|
19
|
+
|
|
20
|
+
-- DropForeignKey
|
|
21
|
+
ALTER TABLE "operator_shift" DROP CONSTRAINT "fk_shift";
|
|
22
|
+
|
|
23
|
+
-- DropForeignKey
|
|
24
|
+
ALTER TABLE "operator_shift" DROP CONSTRAINT "operator_shift_operator_id_fkey";
|
|
25
|
+
|
|
26
|
+
-- DropForeignKey
|
|
27
|
+
ALTER TABLE "operator_shift" DROP CONSTRAINT "operator_shift_tenantId_fkey";
|
|
28
|
+
|
|
29
|
+
-- AlterTable
|
|
30
|
+
ALTER TABLE "break" DROP COLUMN "shiftId",
|
|
31
|
+
ADD COLUMN "shiftDayId" TEXT;
|
|
32
|
+
|
|
33
|
+
-- AlterTable
|
|
34
|
+
ALTER TABLE "operator" ADD COLUMN "shiftId" TEXT;
|
|
35
|
+
|
|
36
|
+
-- AlterTable
|
|
37
|
+
ALTER TABLE "shift" DROP COLUMN "end_time",
|
|
38
|
+
DROP COLUMN "start_time";
|
|
39
|
+
|
|
40
|
+
-- DropTable
|
|
41
|
+
DROP TABLE "_OperatorToShift";
|
|
42
|
+
|
|
43
|
+
-- DropTable
|
|
44
|
+
DROP TABLE "operator_shift";
|
|
45
|
+
|
|
46
|
+
-- CreateTable
|
|
47
|
+
CREATE TABLE "shift_day" (
|
|
48
|
+
"id" TEXT NOT NULL,
|
|
49
|
+
"dayOfWeek" INTEGER NOT NULL,
|
|
50
|
+
"isWorkingDay" BOOLEAN NOT NULL DEFAULT true,
|
|
51
|
+
"start_time" TIME(6),
|
|
52
|
+
"end_time" TIME(6),
|
|
53
|
+
"shiftId" TEXT NOT NULL,
|
|
54
|
+
"tenantId" TEXT,
|
|
55
|
+
|
|
56
|
+
CONSTRAINT "shift_day_pkey" PRIMARY KEY ("id")
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
-- CreateIndex
|
|
60
|
+
CREATE UNIQUE INDEX "shift_day_shiftId_dayOfWeek_key" ON "shift_day"("shiftId", "dayOfWeek");
|
|
61
|
+
|
|
62
|
+
-- AddForeignKey
|
|
63
|
+
ALTER TABLE "break" ADD CONSTRAINT "break_shiftDayId_fkey" FOREIGN KEY ("shiftDayId") REFERENCES "shift_day"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
64
|
+
|
|
65
|
+
-- AddForeignKey
|
|
66
|
+
ALTER TABLE "operator" ADD CONSTRAINT "operator_shiftId_fkey" FOREIGN KEY ("shiftId") REFERENCES "shift"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
67
|
+
|
|
68
|
+
-- AddForeignKey
|
|
69
|
+
ALTER TABLE "shift_day" ADD CONSTRAINT "shift_day_shiftId_fkey" FOREIGN KEY ("shiftId") REFERENCES "shift"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
70
|
+
|
|
71
|
+
-- AddForeignKey
|
|
72
|
+
ALTER TABLE "shift_day" ADD CONSTRAINT "shift_day_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -55,14 +55,16 @@ model Tenant {
|
|
|
55
55
|
sectors Sector[]
|
|
56
56
|
sewMachineRawData SewMachineRawData[]
|
|
57
57
|
shifts Shift[]
|
|
58
|
+
shiftDays ShiftDay[]
|
|
58
59
|
systemPreferences SystemPreferences[]
|
|
59
60
|
processingScripts ProcessingScript[]
|
|
60
61
|
users User[]
|
|
61
62
|
userPermissions UserPermission[]
|
|
62
|
-
operatorShifts OperatorShift[]
|
|
63
63
|
machineOperationStitch MachineOperationStitch[]
|
|
64
64
|
productivityIntervals ProductivityIntervalCache[]
|
|
65
65
|
aiConversations AiConversation[]
|
|
66
|
+
qualityRegisters QualityRegister[]
|
|
67
|
+
qualityIssues QualityIssue[]
|
|
66
68
|
|
|
67
69
|
@@map("tenant")
|
|
68
70
|
}
|
|
@@ -91,13 +93,13 @@ model Account {
|
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
model Break {
|
|
94
|
-
id String
|
|
95
|
-
start_time DateTime
|
|
96
|
-
end_time DateTime
|
|
97
|
-
|
|
96
|
+
id String @id @default(cuid())
|
|
97
|
+
start_time DateTime @db.Time(6)
|
|
98
|
+
end_time DateTime @db.Time(6)
|
|
99
|
+
shiftDayId String?
|
|
98
100
|
tenantId String?
|
|
99
|
-
|
|
100
|
-
tenant Tenant?
|
|
101
|
+
shiftDay ShiftDay? @relation(fields: [shiftDayId], references: [id], onDelete: Cascade)
|
|
102
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
101
103
|
|
|
102
104
|
@@map("break")
|
|
103
105
|
}
|
|
@@ -426,6 +428,7 @@ model Operation {
|
|
|
426
428
|
memberOfGroups OperationGroupMember[] @relation("MemberOperations")
|
|
427
429
|
machineOperationStitch MachineOperationStitch[]
|
|
428
430
|
productivityIntervals ProductivityIntervalCache[]
|
|
431
|
+
qualityRegisters QualityRegister[]
|
|
429
432
|
|
|
430
433
|
@@index([nodeId], map: "idx_operation_node_id")
|
|
431
434
|
@@map("operation")
|
|
@@ -535,9 +538,10 @@ model Operator {
|
|
|
535
538
|
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
536
539
|
ProductionNode ProductionNode?
|
|
537
540
|
habilityResources Resource[] @relation("OperatorToResource")
|
|
538
|
-
|
|
541
|
+
shiftId String?
|
|
542
|
+
shift Shift? @relation(fields: [shiftId], references: [id])
|
|
539
543
|
productivityIntervals ProductivityIntervalCache[]
|
|
540
|
-
|
|
544
|
+
qualityRegisters QualityRegister[]
|
|
541
545
|
|
|
542
546
|
@@index([tenantId, isDeleted])
|
|
543
547
|
@@map("operator")
|
|
@@ -667,6 +671,7 @@ model ProductionOrder {
|
|
|
667
671
|
operationRegisters OperationRegister[]
|
|
668
672
|
productionNode ProductionNode[]
|
|
669
673
|
productivityIntervals ProductivityIntervalCache[]
|
|
674
|
+
qualityRegisters QualityRegister[]
|
|
670
675
|
flow Flow? @relation(fields: [flowId], references: [id])
|
|
671
676
|
Product Product @relation(fields: [productId], references: [id])
|
|
672
677
|
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
@@ -719,15 +724,16 @@ model Resource {
|
|
|
719
724
|
}
|
|
720
725
|
|
|
721
726
|
model Sector {
|
|
722
|
-
id
|
|
723
|
-
name
|
|
724
|
-
description
|
|
725
|
-
isDeleted
|
|
726
|
-
tenantId
|
|
727
|
-
stationFrom
|
|
728
|
-
stationTo
|
|
729
|
-
machines
|
|
730
|
-
tenant
|
|
727
|
+
id String @id @default(cuid())
|
|
728
|
+
name String @unique @db.VarChar(100)
|
|
729
|
+
description String? @db.VarChar(255)
|
|
730
|
+
isDeleted Boolean @default(false)
|
|
731
|
+
tenantId String?
|
|
732
|
+
stationFrom ItemsHandlingRegister[] @relation("sectorFrom")
|
|
733
|
+
stationTo ItemsHandlingRegister[] @relation("sectorTo")
|
|
734
|
+
machines Machine[]
|
|
735
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
736
|
+
qualityRegisters QualityRegister[]
|
|
731
737
|
|
|
732
738
|
@@map("sector")
|
|
733
739
|
}
|
|
@@ -747,19 +753,32 @@ model SewMachineRawData {
|
|
|
747
753
|
}
|
|
748
754
|
|
|
749
755
|
model Shift {
|
|
750
|
-
id
|
|
751
|
-
name
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
tenantId
|
|
755
|
-
|
|
756
|
-
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
757
|
-
operator_shift OperatorShift[]
|
|
758
|
-
operators Operator[] @relation("OperatorToShift")
|
|
756
|
+
id String @id @default(cuid())
|
|
757
|
+
name String @unique @db.VarChar(100)
|
|
758
|
+
tenantId String?
|
|
759
|
+
days ShiftDay[]
|
|
760
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
761
|
+
operators Operator[]
|
|
759
762
|
|
|
760
763
|
@@map("shift")
|
|
761
764
|
}
|
|
762
765
|
|
|
766
|
+
model ShiftDay {
|
|
767
|
+
id String @id @default(cuid())
|
|
768
|
+
dayOfWeek Int // 0 = Domingo, 1 = Segunda, 2 = Terça, ..., 6 = Sábado
|
|
769
|
+
isWorkingDay Boolean @default(true)
|
|
770
|
+
start_time DateTime? @db.Time(6)
|
|
771
|
+
end_time DateTime? @db.Time(6)
|
|
772
|
+
shiftId String
|
|
773
|
+
shift Shift @relation(fields: [shiftId], references: [id], onDelete: Cascade)
|
|
774
|
+
breaks Break[]
|
|
775
|
+
tenantId String?
|
|
776
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
777
|
+
|
|
778
|
+
@@unique([shiftId, dayOfWeek])
|
|
779
|
+
@@map("shift_day")
|
|
780
|
+
}
|
|
781
|
+
|
|
763
782
|
model SystemPreferences {
|
|
764
783
|
id Int @id @default(autoincrement())
|
|
765
784
|
downtimeEventTime Int @default(300)
|
|
@@ -827,18 +846,6 @@ model UserPermission {
|
|
|
827
846
|
@@map("user_permission")
|
|
828
847
|
}
|
|
829
848
|
|
|
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)
|
|
838
|
-
|
|
839
|
-
@@map("operator_shift")
|
|
840
|
-
}
|
|
841
|
-
|
|
842
849
|
view ProductivityInterval {
|
|
843
850
|
machineId String
|
|
844
851
|
sequenceId Int @map("sequence_id")
|
|
@@ -1128,3 +1135,53 @@ model AiFeedback {
|
|
|
1128
1135
|
|
|
1129
1136
|
@@map("ai_feedback")
|
|
1130
1137
|
}
|
|
1138
|
+
|
|
1139
|
+
model QualityRegister {
|
|
1140
|
+
id String @id @default(cuid())
|
|
1141
|
+
timestamp DateTime @default(now())
|
|
1142
|
+
operationId String
|
|
1143
|
+
productionOrderId String?
|
|
1144
|
+
operatorId String?
|
|
1145
|
+
sectorId String?
|
|
1146
|
+
qualityIssueId String?
|
|
1147
|
+
amount Int @default(1)
|
|
1148
|
+
comments String?
|
|
1149
|
+
tenantId String?
|
|
1150
|
+
|
|
1151
|
+
operation Operation @relation(fields: [operationId], references: [id])
|
|
1152
|
+
productionOrder ProductionOrder? @relation(fields: [productionOrderId], references: [id])
|
|
1153
|
+
operator Operator? @relation(fields: [operatorId], references: [id])
|
|
1154
|
+
sector Sector? @relation(fields: [sectorId], references: [id])
|
|
1155
|
+
qualityIssue QualityIssue? @relation(fields: [qualityIssueId], references: [id])
|
|
1156
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1157
|
+
|
|
1158
|
+
@@index([tenantId])
|
|
1159
|
+
@@index([operationId])
|
|
1160
|
+
@@index([productionOrderId])
|
|
1161
|
+
@@index([operatorId])
|
|
1162
|
+
@@index([timestamp])
|
|
1163
|
+
@@map("quality_register")
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
model QualityIssue {
|
|
1167
|
+
id String @id @default(cuid())
|
|
1168
|
+
name String
|
|
1169
|
+
description String?
|
|
1170
|
+
category QualityIssueCategory @default(OTHER)
|
|
1171
|
+
isDeleted Boolean @default(false)
|
|
1172
|
+
tenantId String?
|
|
1173
|
+
|
|
1174
|
+
qualityRegisters QualityRegister[]
|
|
1175
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1176
|
+
|
|
1177
|
+
@@index([tenantId])
|
|
1178
|
+
@@map("quality_issue")
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
enum QualityIssueCategory {
|
|
1182
|
+
HUMAN_ERROR
|
|
1183
|
+
RAW_MATERIAL
|
|
1184
|
+
MACHINE_FAILURE
|
|
1185
|
+
PROCESS_DEVIATION
|
|
1186
|
+
OTHER
|
|
1187
|
+
}
|