@juliobrim/prisma-shared 1.0.20 → 1.0.22
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/20251006123920_update_product_table/migration.sql +6 -0
- package/migrations/20251006134353_add_product_batch_table/migration.sql +22 -0
- package/migrations/20251007032322_update_product_components/migration.sql +2 -0
- package/migrations/20251007200656_update_production_order_table/migration.sql +4 -0
- package/package.json +5 -1
- package/schema.prisma +30 -1
|
@@ -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.
|
|
3
|
+
"version": "1.0.22",
|
|
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
|
@@ -56,6 +56,7 @@ model Tenant {
|
|
|
56
56
|
devices Device[]
|
|
57
57
|
deviceOperators DeviceOperator[]
|
|
58
58
|
machineSensors MachineSensors[]
|
|
59
|
+
productBatches ProductBatch[]
|
|
59
60
|
|
|
60
61
|
@@map("tenant")
|
|
61
62
|
}
|
|
@@ -503,6 +504,12 @@ model Product {
|
|
|
503
504
|
isLocal Boolean?
|
|
504
505
|
isDeleted Boolean @default(false)
|
|
505
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
|
|
506
513
|
flows Flow[]
|
|
507
514
|
itemsHandlingRegisters ItemsHandlingRegister[]
|
|
508
515
|
node Node[]
|
|
@@ -511,6 +518,7 @@ model Product {
|
|
|
511
518
|
componentOf ProductComponents[] @relation("composedBy")
|
|
512
519
|
operations ProductToOperation[]
|
|
513
520
|
productionOrders ProductionOrder[]
|
|
521
|
+
batches ProductBatch[]
|
|
514
522
|
|
|
515
523
|
@@map("product")
|
|
516
524
|
}
|
|
@@ -518,7 +526,7 @@ model Product {
|
|
|
518
526
|
model ProductComponents {
|
|
519
527
|
composedById String
|
|
520
528
|
componentOfId String
|
|
521
|
-
quantity
|
|
529
|
+
quantity Float
|
|
522
530
|
tenantId String?
|
|
523
531
|
componentOf Product @relation("componentOf", fields: [componentOfId], references: [id], onDelete: Cascade)
|
|
524
532
|
composedBy Product @relation("composedBy", fields: [composedById], references: [id], onDelete: Cascade)
|
|
@@ -555,6 +563,9 @@ model ProductionOrder {
|
|
|
555
563
|
flowId String?
|
|
556
564
|
productionOrderIndex Int? @unique
|
|
557
565
|
batchSize Float
|
|
566
|
+
startDate DateTime? @db.Date
|
|
567
|
+
endDate DateTime? @db.Date
|
|
568
|
+
expectedEndDate DateTime? @db.Date
|
|
558
569
|
hasStarted Boolean @default(false)
|
|
559
570
|
isRunning Boolean @default(false)
|
|
560
571
|
isFinished Boolean @default(false)
|
|
@@ -825,6 +836,24 @@ model DeviceOperator {
|
|
|
825
836
|
@@map("device_operator")
|
|
826
837
|
}
|
|
827
838
|
|
|
839
|
+
model ProductBatch {
|
|
840
|
+
id String @id @default(cuid())
|
|
841
|
+
productId String
|
|
842
|
+
batchNumber String // Número do lote
|
|
843
|
+
quantity Float // Quantidade do lote
|
|
844
|
+
expiryDate DateTime @db.Date // Data de validade
|
|
845
|
+
createdAt DateTime @default(now())
|
|
846
|
+
updatedAt DateTime @updatedAt
|
|
847
|
+
tenantId String?
|
|
848
|
+
|
|
849
|
+
// Relacionamentos
|
|
850
|
+
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
851
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
852
|
+
|
|
853
|
+
@@unique([productId, batchNumber])
|
|
854
|
+
@@map("product_batch")
|
|
855
|
+
}
|
|
856
|
+
|
|
828
857
|
enum UserRole {
|
|
829
858
|
ADMIN
|
|
830
859
|
USER
|