@juliobrim/prisma-shared 1.0.18 → 1.0.19
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,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `clientId` on the `device` table. All the data in the column will be lost.
|
|
5
|
+
- You are about to drop the column `name` on the `device` table. All the data in the column will be lost.
|
|
6
|
+
- You are about to drop the column `stationName` on the `device` table. All the data in the column will be lost.
|
|
7
|
+
- You are about to drop the `device_state` table. If the table is not empty, all the data it contains will be lost.
|
|
8
|
+
- Made the column `machineId` on table `device` required. This step will fail if there are existing NULL values in that column.
|
|
9
|
+
- Made the column `tenantId` on table `device` required. This step will fail if there are existing NULL values in that column.
|
|
10
|
+
- Made the column `tenantId` on table `device_operator` required. This step will fail if there are existing NULL values in that column.
|
|
11
|
+
|
|
12
|
+
*/
|
|
13
|
+
-- DropForeignKey
|
|
14
|
+
ALTER TABLE "public"."device" DROP CONSTRAINT "device_machineId_fkey";
|
|
15
|
+
|
|
16
|
+
-- DropForeignKey
|
|
17
|
+
ALTER TABLE "public"."device_state" DROP CONSTRAINT "device_state_deviceId_fkey";
|
|
18
|
+
|
|
19
|
+
-- DropForeignKey
|
|
20
|
+
ALTER TABLE "public"."device_state" DROP CONSTRAINT "device_state_tenantId_fkey";
|
|
21
|
+
|
|
22
|
+
-- DropIndex
|
|
23
|
+
DROP INDEX "public"."device_clientId_key";
|
|
24
|
+
|
|
25
|
+
-- AlterTable
|
|
26
|
+
ALTER TABLE "public"."device" DROP COLUMN "clientId",
|
|
27
|
+
DROP COLUMN "name",
|
|
28
|
+
DROP COLUMN "stationName",
|
|
29
|
+
ADD COLUMN "actualProd" TEXT,
|
|
30
|
+
ADD COLUMN "amountProd" TEXT,
|
|
31
|
+
ADD COLUMN "isOnline" BOOLEAN NOT NULL DEFAULT true,
|
|
32
|
+
ADD COLUMN "lastCommand" TEXT,
|
|
33
|
+
ADD COLUMN "lastSeen" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
34
|
+
ADD COLUMN "plannedProd" TEXT,
|
|
35
|
+
ADD COLUMN "rejectedProd" TEXT,
|
|
36
|
+
ADD COLUMN "runningOpAmount" TEXT,
|
|
37
|
+
ADD COLUMN "runningOpEndDate" TEXT,
|
|
38
|
+
ADD COLUMN "runningOpNumber" TEXT,
|
|
39
|
+
ADD COLUMN "runningOpProduct" TEXT,
|
|
40
|
+
ADD COLUMN "runningOpStartDate" TEXT,
|
|
41
|
+
ALTER COLUMN "machineId" SET NOT NULL,
|
|
42
|
+
ALTER COLUMN "tenantId" SET NOT NULL;
|
|
43
|
+
|
|
44
|
+
-- AlterTable
|
|
45
|
+
ALTER TABLE "public"."device_operator" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
46
|
+
|
|
47
|
+
-- DropTable
|
|
48
|
+
DROP TABLE "public"."device_state";
|
|
49
|
+
|
|
50
|
+
-- AddForeignKey
|
|
51
|
+
ALTER TABLE "public"."device" ADD CONSTRAINT "device_machineId_fkey" FOREIGN KEY ("machineId") REFERENCES "public"."machine"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -55,7 +55,6 @@ model Tenant {
|
|
|
55
55
|
MachineFormulaResult MachineFormulaResult[]
|
|
56
56
|
devices Device[]
|
|
57
57
|
deviceOperators DeviceOperator[]
|
|
58
|
-
deviceStates DeviceState[]
|
|
59
58
|
|
|
60
59
|
@@map("tenant")
|
|
61
60
|
}
|
|
@@ -762,21 +761,29 @@ model NodeOperationQueue {
|
|
|
762
761
|
// Modelos para dispositivos IIoT
|
|
763
762
|
model Device {
|
|
764
763
|
id String @id @default(cuid())
|
|
765
|
-
clientId String @unique // Ex: "SABCON-ESP32-022"
|
|
766
|
-
name String // Nome da estação/device
|
|
767
|
-
stationName String? // Nome da estação (ex: "Estação Montagem A1")
|
|
768
764
|
isActive Boolean @default(true)
|
|
769
765
|
prodReportIntervalSec Int @default(20) // Intervalo de relatório de produção em segundos
|
|
770
|
-
|
|
771
|
-
|
|
766
|
+
plannedProd String? // Produção planejada
|
|
767
|
+
actualProd String? // Produção atual
|
|
768
|
+
amountProd String? // Quantidade produzida (ex: "127 pçs")
|
|
769
|
+
rejectedProd String? // Produção rejeitada
|
|
770
|
+
runningOpNumber String? // Número da operação em execução
|
|
771
|
+
runningOpProduct String? // Produto da operação em execução
|
|
772
|
+
runningOpAmount String? // Quantidade da operação em execução
|
|
773
|
+
runningOpStartDate String? // Data de início da operação em execução
|
|
774
|
+
runningOpEndDate String? // Data de fim da operação em execução
|
|
775
|
+
lastCommand String? // Último comando enviado (ex: "restart")
|
|
776
|
+
isOnline Boolean @default(true)
|
|
777
|
+
lastSeen DateTime @default(now())
|
|
778
|
+
machineId String @unique // Relaciona com uma máquina específica
|
|
779
|
+
tenantId String
|
|
772
780
|
createdAt DateTime @default(now())
|
|
773
781
|
updatedAt DateTime @updatedAt
|
|
774
782
|
|
|
775
783
|
// Relacionamentos
|
|
776
|
-
machine Machine
|
|
777
|
-
tenant Tenant
|
|
784
|
+
machine Machine @relation(fields: [machineId], references: [id])
|
|
785
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
778
786
|
deviceOperators DeviceOperator[]
|
|
779
|
-
deviceStates DeviceState[]
|
|
780
787
|
nodeOperationQueues NodeOperationQueue[]
|
|
781
788
|
|
|
782
789
|
@@map("device")
|
|
@@ -788,46 +795,19 @@ model DeviceOperator {
|
|
|
788
795
|
operatorId String
|
|
789
796
|
pin String? // PIN do operador no dispositivo
|
|
790
797
|
isActive Boolean @default(true)
|
|
791
|
-
tenantId String
|
|
798
|
+
tenantId String
|
|
792
799
|
createdAt DateTime @default(now())
|
|
793
800
|
updatedAt DateTime @updatedAt
|
|
794
801
|
|
|
795
802
|
// Relacionamentos
|
|
796
803
|
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)
|
|
797
804
|
operator Operator @relation(fields: [operatorId], references: [id], onDelete: Cascade)
|
|
798
|
-
tenant Tenant
|
|
805
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
799
806
|
|
|
800
807
|
@@unique([deviceId, operatorId])
|
|
801
808
|
@@map("device_operator")
|
|
802
809
|
}
|
|
803
810
|
|
|
804
|
-
model DeviceState {
|
|
805
|
-
id String @id @default(cuid())
|
|
806
|
-
deviceId String
|
|
807
|
-
plannedProd String? // Produção planejada
|
|
808
|
-
actualProd String? // Produção atual
|
|
809
|
-
amountProd String? // Quantidade produzida (ex: "127 pçs")
|
|
810
|
-
rejectedProd String? // Produção rejeitada
|
|
811
|
-
runningOpNumber String? // Número da operação em execução
|
|
812
|
-
runningOpProduct String? // Produto da operação em execução
|
|
813
|
-
runningOpAmount String? // Quantidade da operação em execução
|
|
814
|
-
runningOpStartDate String? // Data de início da operação em execução
|
|
815
|
-
runningOpEndDate String? // Data de fim da operação em execução
|
|
816
|
-
lastCommand String? // Último comando enviado (ex: "restart")
|
|
817
|
-
isOnline Boolean @default(true)
|
|
818
|
-
lastSeen DateTime @default(now())
|
|
819
|
-
tenantId String?
|
|
820
|
-
createdAt DateTime @default(now())
|
|
821
|
-
updatedAt DateTime @updatedAt
|
|
822
|
-
|
|
823
|
-
// Relacionamentos
|
|
824
|
-
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)
|
|
825
|
-
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
826
|
-
|
|
827
|
-
@@unique([deviceId]) // Um estado por dispositivo
|
|
828
|
-
@@map("device_state")
|
|
829
|
-
}
|
|
830
|
-
|
|
831
811
|
enum UserRole {
|
|
832
812
|
ADMIN
|
|
833
813
|
USER
|