@juliobrim/prisma-shared 1.0.18 → 1.0.20
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;
|
|
@@ -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;
|
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -55,7 +55,7 @@ model Tenant {
|
|
|
55
55
|
MachineFormulaResult MachineFormulaResult[]
|
|
56
56
|
devices Device[]
|
|
57
57
|
deviceOperators DeviceOperator[]
|
|
58
|
-
|
|
58
|
+
machineSensors MachineSensors[]
|
|
59
59
|
|
|
60
60
|
@@map("tenant")
|
|
61
61
|
}
|
|
@@ -255,6 +255,7 @@ model Machine {
|
|
|
255
255
|
MachineFormula MachineFormula[]
|
|
256
256
|
MachineFormulaResult MachineFormulaResult[]
|
|
257
257
|
device Device?
|
|
258
|
+
machineSensors MachineSensors?
|
|
258
259
|
|
|
259
260
|
@@map("machine")
|
|
260
261
|
}
|
|
@@ -762,72 +763,68 @@ model NodeOperationQueue {
|
|
|
762
763
|
// Modelos para dispositivos IIoT
|
|
763
764
|
model Device {
|
|
764
765
|
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
766
|
isActive Boolean @default(true)
|
|
769
767
|
prodReportIntervalSec Int @default(20) // Intervalo de relatório de produção em segundos
|
|
770
|
-
|
|
771
|
-
|
|
768
|
+
plannedProd String? // Produção planejada
|
|
769
|
+
actualProd String? // Produção atual
|
|
770
|
+
amountProd String? // Quantidade produzida (ex: "127 pçs")
|
|
771
|
+
rejectedProd String? // Produção rejeitada
|
|
772
|
+
runningOpNumber String? // Número da operação em execução
|
|
773
|
+
runningOpProduct String? // Produto da operação em execução
|
|
774
|
+
runningOpAmount String? // Quantidade da operação em execução
|
|
775
|
+
runningOpStartDate String? // Data de início da operação em execução
|
|
776
|
+
runningOpEndDate String? // Data de fim da operação em execução
|
|
777
|
+
lastCommand String? // Último comando enviado (ex: "restart")
|
|
778
|
+
isOnline Boolean @default(true)
|
|
779
|
+
lastSeen DateTime @default(now())
|
|
780
|
+
machineId String @unique // Relaciona com uma máquina específica
|
|
781
|
+
tenantId String
|
|
772
782
|
createdAt DateTime @default(now())
|
|
773
783
|
updatedAt DateTime @updatedAt
|
|
774
784
|
|
|
775
785
|
// Relacionamentos
|
|
776
|
-
machine Machine
|
|
777
|
-
tenant Tenant
|
|
786
|
+
machine Machine @relation(fields: [machineId], references: [id])
|
|
787
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
778
788
|
deviceOperators DeviceOperator[]
|
|
779
|
-
deviceStates DeviceState[]
|
|
780
789
|
nodeOperationQueues NodeOperationQueue[]
|
|
781
790
|
|
|
782
791
|
@@map("device")
|
|
783
792
|
}
|
|
784
793
|
|
|
794
|
+
model MachineSensors {
|
|
795
|
+
id String @id @default(cuid())
|
|
796
|
+
machineId String @unique
|
|
797
|
+
sensor1Name String?
|
|
798
|
+
sensor2Name String?
|
|
799
|
+
sensor1Show Boolean @default(true)
|
|
800
|
+
sensor2Show Boolean @default(true)
|
|
801
|
+
tenantId String?
|
|
802
|
+
|
|
803
|
+
machine Machine? @relation(fields: [machineId], references: [id])
|
|
804
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
805
|
+
|
|
806
|
+
@@map("machine_sensors")
|
|
807
|
+
}
|
|
808
|
+
|
|
785
809
|
model DeviceOperator {
|
|
786
810
|
id String @id @default(cuid())
|
|
787
811
|
deviceId String
|
|
788
812
|
operatorId String
|
|
789
813
|
pin String? // PIN do operador no dispositivo
|
|
790
814
|
isActive Boolean @default(true)
|
|
791
|
-
tenantId String
|
|
815
|
+
tenantId String
|
|
792
816
|
createdAt DateTime @default(now())
|
|
793
817
|
updatedAt DateTime @updatedAt
|
|
794
818
|
|
|
795
819
|
// Relacionamentos
|
|
796
820
|
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)
|
|
797
821
|
operator Operator @relation(fields: [operatorId], references: [id], onDelete: Cascade)
|
|
798
|
-
tenant Tenant
|
|
822
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
799
823
|
|
|
800
824
|
@@unique([deviceId, operatorId])
|
|
801
825
|
@@map("device_operator")
|
|
802
826
|
}
|
|
803
827
|
|
|
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
828
|
enum UserRole {
|
|
832
829
|
ADMIN
|
|
833
830
|
USER
|