@juliobrim/prisma-shared 1.0.15 → 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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juliobrim/prisma-shared",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Schema Prisma compartilhado entre projetos Sabcon",
5
5
  "main": "schema.prisma",
6
6
  "files": [
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 String @id @default(cuid())
229
- model String? @db.VarChar(100)
230
- name String @unique @db.VarChar(100)
231
- capacity Float? @db.Real
232
- clp_index String?
233
- acquired_date DateTime? @db.Date
234
- macAddress String? @db.VarChar(17)
235
- isDeleted Boolean @default(false)
236
- sectorId String?
237
- tenantId String?
238
- downtime DowntimeEvent[]
239
- followers Follower[]
240
- inputRegisters InputRegister[]
241
- stationFrom ItemsHandlingRegister[] @relation("stationFrom")
242
- stationTo ItemsHandlingRegister[] @relation("stationTo")
243
- sector Sector? @relation(fields: [sectorId], references: [id])
244
- tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
245
- operationRegister OperationRegister[]
246
- productionNodes ProductionNode?
247
- operationResources Resource[] @relation("MachineToResource")
248
- IotMessageRegister 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