@juliobrim/prisma-shared 1.0.19 → 1.0.21

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,21 @@
1
+ -- CreateTable
2
+ CREATE TABLE "public"."machine_sensors" (
3
+ "id" TEXT NOT NULL,
4
+ "machineId" TEXT NOT NULL,
5
+ "sensor1Name" TEXT,
6
+ "sensor2Name" TEXT,
7
+ "sensor1Show" BOOLEAN NOT NULL DEFAULT true,
8
+ "sensor2Show" BOOLEAN NOT NULL DEFAULT true,
9
+ "tenantId" TEXT,
10
+
11
+ CONSTRAINT "machine_sensors_pkey" PRIMARY KEY ("id")
12
+ );
13
+
14
+ -- CreateIndex
15
+ CREATE UNIQUE INDEX "machine_sensors_machineId_key" ON "public"."machine_sensors"("machineId");
16
+
17
+ -- AddForeignKey
18
+ ALTER TABLE "public"."machine_sensors" ADD CONSTRAINT "machine_sensors_machineId_fkey" FOREIGN KEY ("machineId") REFERENCES "public"."machine"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
19
+
20
+ -- AddForeignKey
21
+ ALTER TABLE "public"."machine_sensors" ADD CONSTRAINT "machine_sensors_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "public"."tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,6 @@
1
+ -- AlterTable
2
+ ALTER TABLE "public"."product" ADD COLUMN "customerProductId" TEXT,
3
+ ADD COLUMN "description" TEXT,
4
+ ADD COLUMN "sku" TEXT,
5
+ ADD COLUMN "stock" DOUBLE PRECISION,
6
+ ADD COLUMN "units" TEXT;
@@ -0,0 +1,22 @@
1
+ -- CreateTable
2
+ CREATE TABLE "public"."product_batch" (
3
+ "id" TEXT NOT NULL,
4
+ "productId" TEXT NOT NULL,
5
+ "batchNumber" TEXT NOT NULL,
6
+ "quantity" DOUBLE PRECISION NOT NULL,
7
+ "expiryDate" DATE NOT NULL,
8
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
9
+ "updatedAt" TIMESTAMP(3) NOT NULL,
10
+ "tenantId" TEXT,
11
+
12
+ CONSTRAINT "product_batch_pkey" PRIMARY KEY ("id")
13
+ );
14
+
15
+ -- CreateIndex
16
+ CREATE UNIQUE INDEX "product_batch_productId_batchNumber_key" ON "public"."product_batch"("productId", "batchNumber");
17
+
18
+ -- AddForeignKey
19
+ ALTER TABLE "public"."product_batch" ADD CONSTRAINT "product_batch_productId_fkey" FOREIGN KEY ("productId") REFERENCES "public"."product"("id") ON DELETE CASCADE ON UPDATE CASCADE;
20
+
21
+ -- AddForeignKey
22
+ ALTER TABLE "public"."product_batch" ADD CONSTRAINT "product_batch_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "public"."tenant"("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.19",
3
+ "version": "1.0.21",
4
4
  "description": "Schema Prisma compartilhado entre projetos Sabcon",
5
5
  "main": "schema.prisma",
6
6
  "files": [
@@ -49,5 +49,9 @@
49
49
  },
50
50
  "engines": {
51
51
  "node": ">=16.0.0"
52
+ },
53
+ "dependencies": {
54
+ "csv-parser": "^3.2.0",
55
+ "xlsx": "^0.18.5"
52
56
  }
53
57
  }
package/schema.prisma CHANGED
@@ -55,6 +55,8 @@ model Tenant {
55
55
  MachineFormulaResult MachineFormulaResult[]
56
56
  devices Device[]
57
57
  deviceOperators DeviceOperator[]
58
+ machineSensors MachineSensors[]
59
+ productBatches ProductBatch[]
58
60
 
59
61
  @@map("tenant")
60
62
  }
@@ -254,6 +256,7 @@ model Machine {
254
256
  MachineFormula MachineFormula[]
255
257
  MachineFormulaResult MachineFormulaResult[]
256
258
  device Device?
259
+ machineSensors MachineSensors?
257
260
 
258
261
  @@map("machine")
259
262
  }
@@ -501,6 +504,12 @@ model Product {
501
504
  isLocal Boolean?
502
505
  isDeleted Boolean @default(false)
503
506
  tenantId String?
507
+ // Campos para importação de produtos do cliente
508
+ customerProductId String? // ID do produto no sistema do cliente
509
+ sku String? // Código SKU do produto
510
+ description String? // Descrição detalhada do produto
511
+ units String? // Unidade de medida (UN, KG, etc.)
512
+ stock Float? // Quantidade em estoque
504
513
  flows Flow[]
505
514
  itemsHandlingRegisters ItemsHandlingRegister[]
506
515
  node Node[]
@@ -509,6 +518,7 @@ model Product {
509
518
  componentOf ProductComponents[] @relation("composedBy")
510
519
  operations ProductToOperation[]
511
520
  productionOrders ProductionOrder[]
521
+ batches ProductBatch[]
512
522
 
513
523
  @@map("product")
514
524
  }
@@ -789,6 +799,21 @@ model Device {
789
799
  @@map("device")
790
800
  }
791
801
 
802
+ model MachineSensors {
803
+ id String @id @default(cuid())
804
+ machineId String @unique
805
+ sensor1Name String?
806
+ sensor2Name String?
807
+ sensor1Show Boolean @default(true)
808
+ sensor2Show Boolean @default(true)
809
+ tenantId String?
810
+
811
+ machine Machine? @relation(fields: [machineId], references: [id])
812
+ tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
813
+
814
+ @@map("machine_sensors")
815
+ }
816
+
792
817
  model DeviceOperator {
793
818
  id String @id @default(cuid())
794
819
  deviceId String
@@ -808,6 +833,24 @@ model DeviceOperator {
808
833
  @@map("device_operator")
809
834
  }
810
835
 
836
+ model ProductBatch {
837
+ id String @id @default(cuid())
838
+ productId String
839
+ batchNumber String // Número do lote
840
+ quantity Float // Quantidade do lote
841
+ expiryDate DateTime @db.Date // Data de validade
842
+ createdAt DateTime @default(now())
843
+ updatedAt DateTime @updatedAt
844
+ tenantId String?
845
+
846
+ // Relacionamentos
847
+ product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
848
+ tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
849
+
850
+ @@unique([productId, batchNumber])
851
+ @@map("product_batch")
852
+ }
853
+
811
854
  enum UserRole {
812
855
  ADMIN
813
856
  USER