@juliobrim/prisma-shared 1.0.14 → 1.0.17
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.
- package/migrations/20250912014516_include_operation_register_time/migration.sql +2 -0
- package/migrations/20250912014733_simplify_column_name/migration.sql +9 -0
- package/migrations/20250919055459_add_tables_machine_formula_and_machine_formula_result/migration.sql +41 -0
- package/package.json +1 -1
- package/schema.prisma +79 -41
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `timeSinceLastOperationRegister` on the `operation_register` table. All the data in the column will be lost.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
-- AlterTable
|
|
8
|
+
ALTER TABLE "public"."operation_register" DROP COLUMN "timeSinceLastOperationRegister",
|
|
9
|
+
ADD COLUMN "timeSinceLastOperation" BIGINT;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "public"."machine_formula" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"machineId" TEXT NOT NULL,
|
|
5
|
+
"name" TEXT NOT NULL,
|
|
6
|
+
"formula" JSONB NOT NULL,
|
|
7
|
+
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
|
8
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
10
|
+
"tenantId" TEXT,
|
|
11
|
+
|
|
12
|
+
CONSTRAINT "machine_formula_pkey" PRIMARY KEY ("id")
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
-- CreateTable
|
|
16
|
+
CREATE TABLE "public"."machine_formula_result" (
|
|
17
|
+
"id" TEXT NOT NULL,
|
|
18
|
+
"machineId" TEXT NOT NULL,
|
|
19
|
+
"formulaId" TEXT NOT NULL,
|
|
20
|
+
"timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
21
|
+
"sensorData" JSONB NOT NULL,
|
|
22
|
+
"result" JSONB NOT NULL,
|
|
23
|
+
"tenantId" TEXT,
|
|
24
|
+
|
|
25
|
+
CONSTRAINT "machine_formula_result_pkey" PRIMARY KEY ("id")
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
-- AddForeignKey
|
|
29
|
+
ALTER TABLE "public"."machine_formula" ADD CONSTRAINT "machine_formula_machineId_fkey" FOREIGN KEY ("machineId") REFERENCES "public"."machine"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
30
|
+
|
|
31
|
+
-- AddForeignKey
|
|
32
|
+
ALTER TABLE "public"."machine_formula" ADD CONSTRAINT "machine_formula_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "public"."tenant"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
33
|
+
|
|
34
|
+
-- AddForeignKey
|
|
35
|
+
ALTER TABLE "public"."machine_formula_result" ADD CONSTRAINT "machine_formula_result_machineId_fkey" FOREIGN KEY ("machineId") REFERENCES "public"."machine"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
36
|
+
|
|
37
|
+
-- AddForeignKey
|
|
38
|
+
ALTER TABLE "public"."machine_formula_result" ADD CONSTRAINT "machine_formula_result_formulaId_fkey" FOREIGN KEY ("formulaId") REFERENCES "public"."machine_formula"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
39
|
+
|
|
40
|
+
-- AddForeignKey
|
|
41
|
+
ALTER TABLE "public"."machine_formula_result" ADD CONSTRAINT "machine_formula_result_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "public"."tenant"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -51,6 +51,8 @@ model Tenant {
|
|
|
51
51
|
userPermissions UserPermission[]
|
|
52
52
|
userShifts UserShift[]
|
|
53
53
|
IotMessageRegister IotMessageRegister[]
|
|
54
|
+
MachineFormula MachineFormula[]
|
|
55
|
+
MachineFormulaResult MachineFormulaResult[]
|
|
54
56
|
|
|
55
57
|
@@map("tenant")
|
|
56
58
|
}
|
|
@@ -225,31 +227,67 @@ model ItemsHandlingRegister {
|
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
model Machine {
|
|
228
|
-
id
|
|
229
|
-
model
|
|
230
|
-
name
|
|
231
|
-
capacity
|
|
232
|
-
clp_index
|
|
233
|
-
acquired_date
|
|
234
|
-
macAddress
|
|
235
|
-
isDeleted
|
|
236
|
-
sectorId
|
|
237
|
-
tenantId
|
|
238
|
-
downtime
|
|
239
|
-
followers
|
|
240
|
-
inputRegisters
|
|
241
|
-
stationFrom
|
|
242
|
-
stationTo
|
|
243
|
-
sector
|
|
244
|
-
tenant
|
|
245
|
-
operationRegister
|
|
246
|
-
productionNodes
|
|
247
|
-
operationResources
|
|
248
|
-
IotMessageRegister
|
|
230
|
+
id String @id @default(cuid())
|
|
231
|
+
model String? @db.VarChar(100)
|
|
232
|
+
name String @unique @db.VarChar(100)
|
|
233
|
+
capacity Float? @db.Real
|
|
234
|
+
clp_index String?
|
|
235
|
+
acquired_date DateTime? @db.Date
|
|
236
|
+
macAddress String? @db.VarChar(17)
|
|
237
|
+
isDeleted Boolean @default(false)
|
|
238
|
+
sectorId String?
|
|
239
|
+
tenantId String?
|
|
240
|
+
downtime DowntimeEvent[]
|
|
241
|
+
followers Follower[]
|
|
242
|
+
inputRegisters InputRegister[]
|
|
243
|
+
stationFrom ItemsHandlingRegister[] @relation("stationFrom")
|
|
244
|
+
stationTo ItemsHandlingRegister[] @relation("stationTo")
|
|
245
|
+
sector Sector? @relation(fields: [sectorId], references: [id])
|
|
246
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
247
|
+
operationRegister OperationRegister[]
|
|
248
|
+
productionNodes ProductionNode?
|
|
249
|
+
operationResources Resource[] @relation("MachineToResource")
|
|
250
|
+
IotMessageRegister IotMessageRegister[]
|
|
251
|
+
MachineFormula MachineFormula[]
|
|
252
|
+
MachineFormulaResult MachineFormulaResult[]
|
|
249
253
|
|
|
250
254
|
@@map("machine")
|
|
251
255
|
}
|
|
252
256
|
|
|
257
|
+
// Estrutura proposta para o banco de dados
|
|
258
|
+
model MachineFormula {
|
|
259
|
+
id String @id @default(cuid())
|
|
260
|
+
machineId String
|
|
261
|
+
name String // "Produção Bruta", "Produção Aprovada", etc.
|
|
262
|
+
formula Json // Fórmula visual serializada
|
|
263
|
+
isActive Boolean @default(true)
|
|
264
|
+
createdAt DateTime @default(now())
|
|
265
|
+
updatedAt DateTime @updatedAt
|
|
266
|
+
tenantId String?
|
|
267
|
+
|
|
268
|
+
machine Machine @relation(fields: [machineId], references: [id])
|
|
269
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id])
|
|
270
|
+
results MachineFormulaResult[]
|
|
271
|
+
|
|
272
|
+
@@map("machine_formula")
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
model MachineFormulaResult {
|
|
276
|
+
id String @id @default(cuid())
|
|
277
|
+
machineId String
|
|
278
|
+
formulaId String
|
|
279
|
+
timestamp DateTime @default(now())
|
|
280
|
+
sensorData Json // Dados dos sensores no momento do cálculo
|
|
281
|
+
result Json // Resultado da fórmula (totalPieces, totalRejected, etc.)
|
|
282
|
+
tenantId String?
|
|
283
|
+
|
|
284
|
+
machine Machine @relation(fields: [machineId], references: [id])
|
|
285
|
+
formula MachineFormula @relation(fields: [formulaId], references: [id])
|
|
286
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id])
|
|
287
|
+
|
|
288
|
+
@@map("machine_formula_result")
|
|
289
|
+
}
|
|
290
|
+
|
|
253
291
|
model Node {
|
|
254
292
|
id String @id @default(cuid())
|
|
255
293
|
positionAbsoluteX Int
|
|
@@ -351,26 +389,26 @@ model OperationGroup {
|
|
|
351
389
|
}
|
|
352
390
|
|
|
353
391
|
model OperationRegister {
|
|
354
|
-
id
|
|
355
|
-
machineId
|
|
356
|
-
operatorId
|
|
357
|
-
operationId
|
|
358
|
-
operationGroupId
|
|
359
|
-
productionOrderId
|
|
360
|
-
startTime
|
|
361
|
-
endTime
|
|
362
|
-
elapsedTime
|
|
363
|
-
|
|
364
|
-
productionNodeId
|
|
365
|
-
tenantId
|
|
366
|
-
quantity
|
|
367
|
-
machine
|
|
368
|
-
operator
|
|
369
|
-
operationGroup
|
|
370
|
-
operation
|
|
371
|
-
productionNode
|
|
372
|
-
productionOrder
|
|
373
|
-
tenant
|
|
392
|
+
id Int @id @default(autoincrement())
|
|
393
|
+
machineId String
|
|
394
|
+
operatorId String
|
|
395
|
+
operationId String?
|
|
396
|
+
operationGroupId Int?
|
|
397
|
+
productionOrderId String
|
|
398
|
+
startTime DateTime @default(now()) @db.Timestamp(6)
|
|
399
|
+
endTime DateTime? @db.Timestamp(6)
|
|
400
|
+
elapsedTime BigInt?
|
|
401
|
+
timeSinceLastOperation BigInt?
|
|
402
|
+
productionNodeId String?
|
|
403
|
+
tenantId String?
|
|
404
|
+
quantity Int @default(1)
|
|
405
|
+
machine Machine @relation(fields: [machineId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_machine")
|
|
406
|
+
operator Operator @relation(fields: [operatorId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_operator")
|
|
407
|
+
operationGroup OperationGroup? @relation(fields: [operationGroupId], references: [id])
|
|
408
|
+
operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
409
|
+
productionNode ProductionNode? @relation(fields: [productionNodeId], references: [id])
|
|
410
|
+
productionOrder ProductionOrder @relation(fields: [productionOrderId], references: [id])
|
|
411
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
374
412
|
|
|
375
413
|
@@map("operation_register")
|
|
376
414
|
}
|