@juliobrim/prisma-shared 1.0.50 → 1.0.52
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/20260323210545_update_schema_for_dynamic_users_permissions/migration.sql +70 -0
- package/migrations/20260324140438_update_role_unique_constraint/migration.sql +6 -0
- package/migrations/20260324171133_remove_ai_chat_tables/migration.sql +25 -0
- package/migrations/20260324174358_hardening_multi_tenant_fields/migration.sql +201 -0
- package/migrations/20260324182918_add_composite_unique_constraints_to_include_tenant_id/migration.sql +67 -0
- package/package.json +1 -1
- package/schema.prisma +142 -207
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `role` on the `user` table. All the data in the column will be lost.
|
|
5
|
+
- You are about to drop the `permission` table. If the table is not empty, all the data it contains will be lost.
|
|
6
|
+
- You are about to drop the `user_permission` table. If the table is not empty, all the data it contains will be lost.
|
|
7
|
+
|
|
8
|
+
*/
|
|
9
|
+
-- DropForeignKey
|
|
10
|
+
ALTER TABLE "user_permission" DROP CONSTRAINT "fk_permission";
|
|
11
|
+
|
|
12
|
+
-- DropForeignKey
|
|
13
|
+
ALTER TABLE "user_permission" DROP CONSTRAINT "user_permission_tenantId_fkey";
|
|
14
|
+
|
|
15
|
+
-- DropForeignKey
|
|
16
|
+
ALTER TABLE "user_permission" DROP CONSTRAINT "user_permission_user_id_fkey";
|
|
17
|
+
|
|
18
|
+
-- AlterTable
|
|
19
|
+
ALTER TABLE "user" DROP COLUMN "role",
|
|
20
|
+
ADD COLUMN "roleId" TEXT;
|
|
21
|
+
|
|
22
|
+
-- DropTable
|
|
23
|
+
DROP TABLE "permission";
|
|
24
|
+
|
|
25
|
+
-- DropTable
|
|
26
|
+
DROP TABLE "user_permission";
|
|
27
|
+
|
|
28
|
+
-- CreateTable
|
|
29
|
+
CREATE TABLE "Permission" (
|
|
30
|
+
"id" TEXT NOT NULL,
|
|
31
|
+
"action" TEXT NOT NULL,
|
|
32
|
+
"subject" TEXT NOT NULL,
|
|
33
|
+
"conditions" JSONB,
|
|
34
|
+
"description" TEXT,
|
|
35
|
+
|
|
36
|
+
CONSTRAINT "Permission_pkey" PRIMARY KEY ("id")
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
-- CreateTable
|
|
40
|
+
CREATE TABLE "Role" (
|
|
41
|
+
"id" TEXT NOT NULL,
|
|
42
|
+
"name" TEXT NOT NULL,
|
|
43
|
+
"description" TEXT,
|
|
44
|
+
"tenantId" TEXT,
|
|
45
|
+
|
|
46
|
+
CONSTRAINT "Role_pkey" PRIMARY KEY ("id")
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
-- CreateTable
|
|
50
|
+
CREATE TABLE "RolePermission" (
|
|
51
|
+
"roleId" TEXT NOT NULL,
|
|
52
|
+
"permissionId" TEXT NOT NULL,
|
|
53
|
+
|
|
54
|
+
CONSTRAINT "RolePermission_pkey" PRIMARY KEY ("roleId","permissionId")
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
-- CreateIndex
|
|
58
|
+
CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name");
|
|
59
|
+
|
|
60
|
+
-- AddForeignKey
|
|
61
|
+
ALTER TABLE "Role" ADD CONSTRAINT "Role_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
62
|
+
|
|
63
|
+
-- AddForeignKey
|
|
64
|
+
ALTER TABLE "RolePermission" ADD CONSTRAINT "RolePermission_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
65
|
+
|
|
66
|
+
-- AddForeignKey
|
|
67
|
+
ALTER TABLE "RolePermission" ADD CONSTRAINT "RolePermission_permissionId_fkey" FOREIGN KEY ("permissionId") REFERENCES "Permission"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
68
|
+
|
|
69
|
+
-- AddForeignKey
|
|
70
|
+
ALTER TABLE "user" ADD CONSTRAINT "user_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the `ai_conversation` table. If the table is not empty, all the data it contains will be lost.
|
|
5
|
+
- You are about to drop the `ai_feedback` table. If the table is not empty, all the data it contains will be lost.
|
|
6
|
+
- You are about to drop the `ai_message` table. If the table is not empty, all the data it contains will be lost.
|
|
7
|
+
|
|
8
|
+
*/
|
|
9
|
+
-- DropForeignKey
|
|
10
|
+
ALTER TABLE "ai_conversation" DROP CONSTRAINT "ai_conversation_tenantId_fkey";
|
|
11
|
+
|
|
12
|
+
-- DropForeignKey
|
|
13
|
+
ALTER TABLE "ai_conversation" DROP CONSTRAINT "ai_conversation_userId_fkey";
|
|
14
|
+
|
|
15
|
+
-- DropForeignKey
|
|
16
|
+
ALTER TABLE "ai_message" DROP CONSTRAINT "ai_message_conversationId_fkey";
|
|
17
|
+
|
|
18
|
+
-- DropTable
|
|
19
|
+
DROP TABLE "ai_conversation";
|
|
20
|
+
|
|
21
|
+
-- DropTable
|
|
22
|
+
DROP TABLE "ai_feedback";
|
|
23
|
+
|
|
24
|
+
-- DropTable
|
|
25
|
+
DROP TABLE "ai_message";
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the `machine_formula` table. If the table is not empty, all the data it contains will be lost.
|
|
5
|
+
- You are about to drop the `machine_formula_result` table. If the table is not empty, all the data it contains will be lost.
|
|
6
|
+
- Made the column `tenantId` on table `Role` required. This step will fail if there are existing NULL values in that column.
|
|
7
|
+
- Made the column `tenantId` on table `break` required. This step will fail if there are existing NULL values in that column.
|
|
8
|
+
- Made the column `tenantId` on table `downtime_event` required. This step will fail if there are existing NULL values in that column.
|
|
9
|
+
- Made the column `tenantId` on table `downtime_reason` required. This step will fail if there are existing NULL values in that column.
|
|
10
|
+
- Made the column `tenantId` on table `edge` required. This step will fail if there are existing NULL values in that column.
|
|
11
|
+
- Made the column `tenantId` on table `flow` required. This step will fail if there are existing NULL values in that column.
|
|
12
|
+
- Made the column `tenantId` on table `follower` required. This step will fail if there are existing NULL values in that column.
|
|
13
|
+
- Made the column `tenantId` on table `input_register` required. This step will fail if there are existing NULL values in that column.
|
|
14
|
+
- Made the column `tenantId` on table `iot_message_register` required. This step will fail if there are existing NULL values in that column.
|
|
15
|
+
- Made the column `tenantId` on table `items_handling_register` required. This step will fail if there are existing NULL values in that column.
|
|
16
|
+
- Made the column `tenantId` on table `machine` required. This step will fail if there are existing NULL values in that column.
|
|
17
|
+
- Made the column `tenantId` on table `machine_operation_stitch` required. This step will fail if there are existing NULL values in that column.
|
|
18
|
+
- Made the column `tenantId` on table `machine_sensors` required. This step will fail if there are existing NULL values in that column.
|
|
19
|
+
- Made the column `tenantId` on table `node` required. This step will fail if there are existing NULL values in that column.
|
|
20
|
+
- Made the column `tenantId` on table `node_operation_queue` required. This step will fail if there are existing NULL values in that column.
|
|
21
|
+
- Made the column `tenantId` on table `notification` required. This step will fail if there are existing NULL values in that column.
|
|
22
|
+
- Made the column `tenantId` on table `notification_to_user` required. This step will fail if there are existing NULL values in that column.
|
|
23
|
+
- Made the column `tenantId` on table `operation` required. This step will fail if there are existing NULL values in that column.
|
|
24
|
+
- Made the column `tenantId` on table `operation_group` required. This step will fail if there are existing NULL values in that column.
|
|
25
|
+
- Made the column `tenantId` on table `operation_register` required. This step will fail if there are existing NULL values in that column.
|
|
26
|
+
- Made the column `tenantId` on table `operation_to_operation` required. This step will fail if there are existing NULL values in that column.
|
|
27
|
+
- Made the column `tenantId` on table `operator` required. This step will fail if there are existing NULL values in that column.
|
|
28
|
+
- Made the column `tenantId` on table `operator_availability_cache` required. This step will fail if there are existing NULL values in that column.
|
|
29
|
+
- Made the column `tenantId` on table `operator_role` required. This step will fail if there are existing NULL values in that column.
|
|
30
|
+
- Made the column `tenantId` on table `panel` required. This step will fail if there are existing NULL values in that column.
|
|
31
|
+
- Made the column `tenantId` on table `product` required. This step will fail if there are existing NULL values in that column.
|
|
32
|
+
- Made the column `tenantId` on table `product_batch` required. This step will fail if there are existing NULL values in that column.
|
|
33
|
+
- Made the column `tenantId` on table `product_components` required. This step will fail if there are existing NULL values in that column.
|
|
34
|
+
- Made the column `tenantId` on table `product_to_operation` required. This step will fail if there are existing NULL values in that column.
|
|
35
|
+
- Made the column `tenantId` on table `production_node` required. This step will fail if there are existing NULL values in that column.
|
|
36
|
+
- Made the column `tenantId` on table `production_order` required. This step will fail if there are existing NULL values in that column.
|
|
37
|
+
- Made the column `tenantId` on table `productivity_interval_cache` required. This step will fail if there are existing NULL values in that column.
|
|
38
|
+
- Made the column `tenantId` on table `quality_issue` required. This step will fail if there are existing NULL values in that column.
|
|
39
|
+
- Made the column `tenantId` on table `quality_register` required. This step will fail if there are existing NULL values in that column.
|
|
40
|
+
- Made the column `tenantId` on table `report` required. This step will fail if there are existing NULL values in that column.
|
|
41
|
+
- Made the column `tenantId` on table `resource` required. This step will fail if there are existing NULL values in that column.
|
|
42
|
+
- Made the column `tenantId` on table `sector` required. This step will fail if there are existing NULL values in that column.
|
|
43
|
+
- Made the column `tenantId` on table `sew_machine_raw_data` required. This step will fail if there are existing NULL values in that column.
|
|
44
|
+
- Made the column `tenantId` on table `shift` required. This step will fail if there are existing NULL values in that column.
|
|
45
|
+
- Made the column `tenantId` on table `shift_day` required. This step will fail if there are existing NULL values in that column.
|
|
46
|
+
- Made the column `tenantId` on table `system_preferences` required. This step will fail if there are existing NULL values in that column.
|
|
47
|
+
- Made the column `tenantId` on table `user` required. This step will fail if there are existing NULL values in that column.
|
|
48
|
+
|
|
49
|
+
*/
|
|
50
|
+
-- DropForeignKey
|
|
51
|
+
ALTER TABLE "Role" DROP CONSTRAINT "Role_tenantId_fkey";
|
|
52
|
+
|
|
53
|
+
-- DropForeignKey
|
|
54
|
+
ALTER TABLE "machine_formula" DROP CONSTRAINT "machine_formula_machineId_fkey";
|
|
55
|
+
|
|
56
|
+
-- DropForeignKey
|
|
57
|
+
ALTER TABLE "machine_formula" DROP CONSTRAINT "machine_formula_tenantId_fkey";
|
|
58
|
+
|
|
59
|
+
-- DropForeignKey
|
|
60
|
+
ALTER TABLE "machine_formula_result" DROP CONSTRAINT "machine_formula_result_formulaId_fkey";
|
|
61
|
+
|
|
62
|
+
-- DropForeignKey
|
|
63
|
+
ALTER TABLE "machine_formula_result" DROP CONSTRAINT "machine_formula_result_machineId_fkey";
|
|
64
|
+
|
|
65
|
+
-- DropForeignKey
|
|
66
|
+
ALTER TABLE "machine_formula_result" DROP CONSTRAINT "machine_formula_result_tenantId_fkey";
|
|
67
|
+
|
|
68
|
+
-- AlterTable
|
|
69
|
+
ALTER TABLE "Role" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
70
|
+
|
|
71
|
+
-- AlterTable
|
|
72
|
+
ALTER TABLE "break" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
73
|
+
|
|
74
|
+
-- AlterTable
|
|
75
|
+
ALTER TABLE "downtime_event" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
76
|
+
|
|
77
|
+
-- AlterTable
|
|
78
|
+
ALTER TABLE "downtime_reason" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
79
|
+
|
|
80
|
+
-- AlterTable
|
|
81
|
+
ALTER TABLE "edge" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
82
|
+
|
|
83
|
+
-- AlterTable
|
|
84
|
+
ALTER TABLE "flow" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
85
|
+
|
|
86
|
+
-- AlterTable
|
|
87
|
+
ALTER TABLE "follower" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
88
|
+
|
|
89
|
+
-- AlterTable
|
|
90
|
+
ALTER TABLE "input_register" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
91
|
+
|
|
92
|
+
-- AlterTable
|
|
93
|
+
ALTER TABLE "iot_message_register" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
94
|
+
|
|
95
|
+
-- AlterTable
|
|
96
|
+
ALTER TABLE "items_handling_register" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
97
|
+
|
|
98
|
+
-- AlterTable
|
|
99
|
+
ALTER TABLE "machine" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
100
|
+
|
|
101
|
+
-- AlterTable
|
|
102
|
+
ALTER TABLE "machine_operation_stitch" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
103
|
+
|
|
104
|
+
-- AlterTable
|
|
105
|
+
ALTER TABLE "machine_sensors" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
106
|
+
|
|
107
|
+
-- AlterTable
|
|
108
|
+
ALTER TABLE "node" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
109
|
+
|
|
110
|
+
-- AlterTable
|
|
111
|
+
ALTER TABLE "node_operation_queue" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
112
|
+
|
|
113
|
+
-- AlterTable
|
|
114
|
+
ALTER TABLE "notification" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
115
|
+
|
|
116
|
+
-- AlterTable
|
|
117
|
+
ALTER TABLE "notification_to_user" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
118
|
+
|
|
119
|
+
-- AlterTable
|
|
120
|
+
ALTER TABLE "operation" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
121
|
+
|
|
122
|
+
-- AlterTable
|
|
123
|
+
ALTER TABLE "operation_group" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
124
|
+
|
|
125
|
+
-- AlterTable
|
|
126
|
+
ALTER TABLE "operation_register" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
127
|
+
|
|
128
|
+
-- AlterTable
|
|
129
|
+
ALTER TABLE "operation_to_operation" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
130
|
+
|
|
131
|
+
-- AlterTable
|
|
132
|
+
ALTER TABLE "operator" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
133
|
+
|
|
134
|
+
-- AlterTable
|
|
135
|
+
ALTER TABLE "operator_availability_cache" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
136
|
+
|
|
137
|
+
-- AlterTable
|
|
138
|
+
ALTER TABLE "operator_role" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
139
|
+
|
|
140
|
+
-- AlterTable
|
|
141
|
+
ALTER TABLE "panel" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
142
|
+
|
|
143
|
+
-- AlterTable
|
|
144
|
+
ALTER TABLE "product" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
145
|
+
|
|
146
|
+
-- AlterTable
|
|
147
|
+
ALTER TABLE "product_batch" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
148
|
+
|
|
149
|
+
-- AlterTable
|
|
150
|
+
ALTER TABLE "product_components" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
151
|
+
|
|
152
|
+
-- AlterTable
|
|
153
|
+
ALTER TABLE "product_to_operation" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
154
|
+
|
|
155
|
+
-- AlterTable
|
|
156
|
+
ALTER TABLE "production_node" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
157
|
+
|
|
158
|
+
-- AlterTable
|
|
159
|
+
ALTER TABLE "production_order" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
160
|
+
|
|
161
|
+
-- AlterTable
|
|
162
|
+
ALTER TABLE "productivity_interval_cache" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
163
|
+
|
|
164
|
+
-- AlterTable
|
|
165
|
+
ALTER TABLE "quality_issue" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
166
|
+
|
|
167
|
+
-- AlterTable
|
|
168
|
+
ALTER TABLE "quality_register" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
169
|
+
|
|
170
|
+
-- AlterTable
|
|
171
|
+
ALTER TABLE "report" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
172
|
+
|
|
173
|
+
-- AlterTable
|
|
174
|
+
ALTER TABLE "resource" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
175
|
+
|
|
176
|
+
-- AlterTable
|
|
177
|
+
ALTER TABLE "sector" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
178
|
+
|
|
179
|
+
-- AlterTable
|
|
180
|
+
ALTER TABLE "sew_machine_raw_data" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
181
|
+
|
|
182
|
+
-- AlterTable
|
|
183
|
+
ALTER TABLE "shift" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
184
|
+
|
|
185
|
+
-- AlterTable
|
|
186
|
+
ALTER TABLE "shift_day" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
187
|
+
|
|
188
|
+
-- AlterTable
|
|
189
|
+
ALTER TABLE "system_preferences" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
190
|
+
|
|
191
|
+
-- AlterTable
|
|
192
|
+
ALTER TABLE "user" ALTER COLUMN "tenantId" SET NOT NULL;
|
|
193
|
+
|
|
194
|
+
-- DropTable
|
|
195
|
+
DROP TABLE "machine_formula";
|
|
196
|
+
|
|
197
|
+
-- DropTable
|
|
198
|
+
DROP TABLE "machine_formula_result";
|
|
199
|
+
|
|
200
|
+
-- AddForeignKey
|
|
201
|
+
ALTER TABLE "Role" ADD CONSTRAINT "Role_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- A unique constraint covering the columns `[tenantId,name]` on the table `downtime_reason` will be added. If there are existing duplicate values, this will fail.
|
|
5
|
+
- A unique constraint covering the columns `[tenantId,name]` on the table `machine` will be added. If there are existing duplicate values, this will fail.
|
|
6
|
+
- A unique constraint covering the columns `[tenantId,name]` on the table `operator` will be added. If there are existing duplicate values, this will fail.
|
|
7
|
+
- A unique constraint covering the columns `[tenantId,productId,batchNumber,internalBatchNumber]` on the table `product_batch` will be added. If there are existing duplicate values, this will fail.
|
|
8
|
+
- A unique constraint covering the columns `[tenantId,productionOrderIndex]` on the table `production_order` will be added. If there are existing duplicate values, this will fail.
|
|
9
|
+
- A unique constraint covering the columns `[tenantId,name]` on the table `resource` will be added. If there are existing duplicate values, this will fail.
|
|
10
|
+
- A unique constraint covering the columns `[tenantId,name]` on the table `sector` will be added. If there are existing duplicate values, this will fail.
|
|
11
|
+
- A unique constraint covering the columns `[tenantId,name]` on the table `shift` will be added. If there are existing duplicate values, this will fail.
|
|
12
|
+
- A unique constraint covering the columns `[tenantId,email]` on the table `user` will be added. If there are existing duplicate values, this will fail.
|
|
13
|
+
|
|
14
|
+
*/
|
|
15
|
+
-- DropIndex
|
|
16
|
+
DROP INDEX "downtime_reason_name_key";
|
|
17
|
+
|
|
18
|
+
-- DropIndex
|
|
19
|
+
DROP INDEX "machine_name_key";
|
|
20
|
+
|
|
21
|
+
-- DropIndex
|
|
22
|
+
DROP INDEX "operator_name_key";
|
|
23
|
+
|
|
24
|
+
-- DropIndex
|
|
25
|
+
DROP INDEX "product_batch_productId_batchNumber_internalBatchNumber_key";
|
|
26
|
+
|
|
27
|
+
-- DropIndex
|
|
28
|
+
DROP INDEX "production_order_productionOrderIndex_key";
|
|
29
|
+
|
|
30
|
+
-- DropIndex
|
|
31
|
+
DROP INDEX "resource_name_key";
|
|
32
|
+
|
|
33
|
+
-- DropIndex
|
|
34
|
+
DROP INDEX "sector_name_key";
|
|
35
|
+
|
|
36
|
+
-- DropIndex
|
|
37
|
+
DROP INDEX "shift_name_key";
|
|
38
|
+
|
|
39
|
+
-- DropIndex
|
|
40
|
+
DROP INDEX "user_email_key";
|
|
41
|
+
|
|
42
|
+
-- CreateIndex
|
|
43
|
+
CREATE UNIQUE INDEX "downtime_reason_tenantId_name_key" ON "downtime_reason"("tenantId", "name");
|
|
44
|
+
|
|
45
|
+
-- CreateIndex
|
|
46
|
+
CREATE UNIQUE INDEX "machine_tenantId_name_key" ON "machine"("tenantId", "name");
|
|
47
|
+
|
|
48
|
+
-- CreateIndex
|
|
49
|
+
CREATE UNIQUE INDEX "operator_tenantId_name_key" ON "operator"("tenantId", "name");
|
|
50
|
+
|
|
51
|
+
-- CreateIndex
|
|
52
|
+
CREATE UNIQUE INDEX "product_batch_tenantId_productId_batchNumber_internalBatchN_key" ON "product_batch"("tenantId", "productId", "batchNumber", "internalBatchNumber");
|
|
53
|
+
|
|
54
|
+
-- CreateIndex
|
|
55
|
+
CREATE UNIQUE INDEX "production_order_tenantId_productionOrderIndex_key" ON "production_order"("tenantId", "productionOrderIndex");
|
|
56
|
+
|
|
57
|
+
-- CreateIndex
|
|
58
|
+
CREATE UNIQUE INDEX "resource_tenantId_name_key" ON "resource"("tenantId", "name");
|
|
59
|
+
|
|
60
|
+
-- CreateIndex
|
|
61
|
+
CREATE UNIQUE INDEX "sector_tenantId_name_key" ON "sector"("tenantId", "name");
|
|
62
|
+
|
|
63
|
+
-- CreateIndex
|
|
64
|
+
CREATE UNIQUE INDEX "shift_tenantId_name_key" ON "shift"("tenantId", "name");
|
|
65
|
+
|
|
66
|
+
-- CreateIndex
|
|
67
|
+
CREATE UNIQUE INDEX "user_tenantId_email_key" ON "user"("tenantId", "email");
|
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -29,8 +29,6 @@ model Tenant {
|
|
|
29
29
|
IotMessageRegister IotMessageRegister[]
|
|
30
30
|
itemsHandlingRegisters ItemsHandlingRegister[]
|
|
31
31
|
machines Machine[]
|
|
32
|
-
MachineFormula MachineFormula[]
|
|
33
|
-
MachineFormulaResult MachineFormulaResult[]
|
|
34
32
|
machineSensors MachineSensors[]
|
|
35
33
|
nodes Node[]
|
|
36
34
|
nodeOperationQueue NodeOperationQueue[]
|
|
@@ -59,11 +57,10 @@ model Tenant {
|
|
|
59
57
|
systemPreferences SystemPreferences[]
|
|
60
58
|
processingScripts ProcessingScript[]
|
|
61
59
|
users User[]
|
|
62
|
-
|
|
60
|
+
roles Role[]
|
|
63
61
|
machineOperationStitch MachineOperationStitch[]
|
|
64
62
|
productivityIntervals ProductivityIntervalCache[]
|
|
65
63
|
operatorAvailability OperatorAvailabilityCache[]
|
|
66
|
-
aiConversations AiConversation[]
|
|
67
64
|
qualityRegisters QualityRegister[]
|
|
68
65
|
qualityIssues QualityIssue[]
|
|
69
66
|
|
|
@@ -98,9 +95,9 @@ model Break {
|
|
|
98
95
|
start_time DateTime @db.Time(6)
|
|
99
96
|
end_time DateTime @db.Time(6)
|
|
100
97
|
shiftDayId String?
|
|
101
|
-
tenantId String
|
|
98
|
+
tenantId String
|
|
102
99
|
shiftDay ShiftDay? @relation(fields: [shiftDayId], references: [id], onDelete: Cascade)
|
|
103
|
-
tenant Tenant
|
|
100
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
104
101
|
|
|
105
102
|
@@map("break")
|
|
106
103
|
}
|
|
@@ -116,8 +113,8 @@ model DowntimeEvent {
|
|
|
116
113
|
end_time DateTime?
|
|
117
114
|
elapsedTime BigInt?
|
|
118
115
|
isJustified Boolean @default(false)
|
|
119
|
-
tenantId String
|
|
120
|
-
tenant Tenant
|
|
116
|
+
tenantId String
|
|
117
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
121
118
|
downtimeReason DowntimeReason? @relation(fields: [downtimeReasonId], references: [id], onUpdate: NoAction, map: "fk_downtimeReason")
|
|
122
119
|
machine Machine @relation(fields: [machine_id], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "fk_machine")
|
|
123
120
|
operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade, map: "fk_operation")
|
|
@@ -134,14 +131,15 @@ model DowntimeEvent {
|
|
|
134
131
|
|
|
135
132
|
model DowntimeReason {
|
|
136
133
|
id String @id @default(cuid())
|
|
137
|
-
name String @
|
|
134
|
+
name String @db.VarChar(100)
|
|
138
135
|
description String? @db.VarChar(255)
|
|
139
136
|
isImpactful Boolean @default(false)
|
|
140
137
|
isDeleted Boolean @default(false)
|
|
141
|
-
tenantId String
|
|
138
|
+
tenantId String
|
|
142
139
|
downtime DowntimeEvent[]
|
|
143
|
-
tenant Tenant
|
|
140
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
144
141
|
|
|
142
|
+
@@unique([tenantId, name])
|
|
145
143
|
@@map("downtime_reason")
|
|
146
144
|
}
|
|
147
145
|
|
|
@@ -149,10 +147,10 @@ model Edge {
|
|
|
149
147
|
amount Int
|
|
150
148
|
inputNodeId String
|
|
151
149
|
outputNodeId String
|
|
152
|
-
tenantId String
|
|
153
|
-
inputNode Node
|
|
154
|
-
outputNode Node
|
|
155
|
-
tenant Tenant
|
|
150
|
+
tenantId String
|
|
151
|
+
inputNode Node @relation("inputNode", fields: [inputNodeId], references: [id], onDelete: Cascade)
|
|
152
|
+
outputNode Node @relation("outputNode", fields: [outputNodeId], references: [id], onDelete: Cascade)
|
|
153
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
156
154
|
|
|
157
155
|
@@id([inputNodeId, outputNodeId])
|
|
158
156
|
@@map("edge")
|
|
@@ -163,9 +161,9 @@ model Flow {
|
|
|
163
161
|
title String
|
|
164
162
|
productId String?
|
|
165
163
|
isDeleted Boolean @default(false)
|
|
166
|
-
tenantId String
|
|
164
|
+
tenantId String
|
|
167
165
|
product Product? @relation(fields: [productId], references: [id])
|
|
168
|
-
tenant Tenant
|
|
166
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
169
167
|
nodes Node[]
|
|
170
168
|
operationGroups OperationGroup[]
|
|
171
169
|
productionOrders ProductionOrder[]
|
|
@@ -176,9 +174,9 @@ model Flow {
|
|
|
176
174
|
model Follower {
|
|
177
175
|
userId String
|
|
178
176
|
machineId String
|
|
179
|
-
tenantId String
|
|
177
|
+
tenantId String
|
|
180
178
|
machine Machine @relation(fields: [machineId], references: [id])
|
|
181
|
-
tenant Tenant
|
|
179
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
182
180
|
user User @relation(fields: [userId], references: [id])
|
|
183
181
|
|
|
184
182
|
@@id([userId, machineId])
|
|
@@ -193,13 +191,13 @@ model InputRegister {
|
|
|
193
191
|
in4Count BigInt @map("in4_count")
|
|
194
192
|
timestamp DateTime @default(now())
|
|
195
193
|
machineId String
|
|
196
|
-
tenantId String
|
|
194
|
+
tenantId String
|
|
197
195
|
operationId String?
|
|
198
196
|
productionOrderId String?
|
|
199
197
|
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
200
198
|
operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
201
199
|
productionOrder ProductionOrder? @relation(fields: [productionOrderId], references: [id], onDelete: Cascade)
|
|
202
|
-
tenant Tenant
|
|
200
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
203
201
|
|
|
204
202
|
@@index([machineId, timestamp])
|
|
205
203
|
@@index([productionOrderId])
|
|
@@ -219,9 +217,9 @@ model IotMessageRegister {
|
|
|
219
217
|
di3State Boolean @map("di3_state")
|
|
220
218
|
di4State Boolean @map("di4_state")
|
|
221
219
|
machineId String
|
|
222
|
-
tenantId String
|
|
220
|
+
tenantId String
|
|
223
221
|
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
224
|
-
tenant Tenant
|
|
222
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
225
223
|
|
|
226
224
|
@@index([machineId, timestamp])
|
|
227
225
|
@@map("iot_message_register")
|
|
@@ -238,7 +236,7 @@ model ItemsHandlingRegister {
|
|
|
238
236
|
sectorFromId String?
|
|
239
237
|
sectorToId String?
|
|
240
238
|
timestamp DateTime @default(now())
|
|
241
|
-
tenantId String
|
|
239
|
+
tenantId String
|
|
242
240
|
operation Operation? @relation(fields: [operationId], references: [id])
|
|
243
241
|
product Product? @relation(fields: [productId], references: [id])
|
|
244
242
|
productionOrder ProductionOrder @relation(fields: [productionOrderId], references: [id])
|
|
@@ -246,7 +244,7 @@ model ItemsHandlingRegister {
|
|
|
246
244
|
sectorTo Sector? @relation("sectorTo", fields: [sectorToId], references: [id])
|
|
247
245
|
stationFrom Machine? @relation("stationFrom", fields: [stationFromId], references: [id])
|
|
248
246
|
stationTo Machine? @relation("stationTo", fields: [stationToId], references: [id])
|
|
249
|
-
tenant Tenant
|
|
247
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
250
248
|
|
|
251
249
|
@@index([productionOrderId])
|
|
252
250
|
@@index([productId])
|
|
@@ -258,14 +256,14 @@ model ItemsHandlingRegister {
|
|
|
258
256
|
model Machine {
|
|
259
257
|
id String @id @default(cuid())
|
|
260
258
|
model String? @db.VarChar(100)
|
|
261
|
-
name String @
|
|
259
|
+
name String @db.VarChar(100)
|
|
262
260
|
capacity Float? @db.Real
|
|
263
261
|
clp_index String?
|
|
264
262
|
acquired_date DateTime? @db.Date
|
|
265
263
|
macAddress String? @db.VarChar(17)
|
|
266
264
|
isDeleted Boolean @default(false)
|
|
267
265
|
sectorId String?
|
|
268
|
-
tenantId String
|
|
266
|
+
tenantId String
|
|
269
267
|
type MachineType? @default(discrete)
|
|
270
268
|
device Device?
|
|
271
269
|
downtime DowntimeEvent[]
|
|
@@ -275,9 +273,7 @@ model Machine {
|
|
|
275
273
|
stationFrom ItemsHandlingRegister[] @relation("stationFrom")
|
|
276
274
|
stationTo ItemsHandlingRegister[] @relation("stationTo")
|
|
277
275
|
sector Sector? @relation(fields: [sectorId], references: [id])
|
|
278
|
-
tenant Tenant
|
|
279
|
-
MachineFormula MachineFormula[]
|
|
280
|
-
MachineFormulaResult MachineFormulaResult[]
|
|
276
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
281
277
|
machineSensors MachineSensors?
|
|
282
278
|
operationRegister OperationRegister[]
|
|
283
279
|
productionNodes ProductionNode?
|
|
@@ -289,6 +285,7 @@ model Machine {
|
|
|
289
285
|
machineOperationStitch MachineOperationStitch[]
|
|
290
286
|
productivityIntervals ProductivityIntervalCache[]
|
|
291
287
|
|
|
288
|
+
@@unique([tenantId, name])
|
|
292
289
|
@@index([sectorId])
|
|
293
290
|
@@index([tenantId])
|
|
294
291
|
@@index([isDeleted])
|
|
@@ -313,39 +310,6 @@ model ProcessingScript {
|
|
|
313
310
|
@@map("processing_script")
|
|
314
311
|
}
|
|
315
312
|
|
|
316
|
-
model MachineFormula {
|
|
317
|
-
id String @id @default(cuid())
|
|
318
|
-
machineId String
|
|
319
|
-
name String
|
|
320
|
-
formula Json
|
|
321
|
-
isActive Boolean @default(true)
|
|
322
|
-
createdAt DateTime @default(now())
|
|
323
|
-
updatedAt DateTime @updatedAt
|
|
324
|
-
tenantId String?
|
|
325
|
-
machine Machine @relation(fields: [machineId], references: [id])
|
|
326
|
-
tenant Tenant? @relation(fields: [tenantId], references: [id])
|
|
327
|
-
results MachineFormulaResult[]
|
|
328
|
-
|
|
329
|
-
@@map("machine_formula")
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
model MachineFormulaResult {
|
|
333
|
-
id String @id @default(cuid())
|
|
334
|
-
machineId String
|
|
335
|
-
formulaId String
|
|
336
|
-
timestamp DateTime @default(now())
|
|
337
|
-
sensorData Json
|
|
338
|
-
result Json
|
|
339
|
-
tenantId String?
|
|
340
|
-
formula MachineFormula @relation(fields: [formulaId], references: [id])
|
|
341
|
-
machine Machine @relation(fields: [machineId], references: [id])
|
|
342
|
-
tenant Tenant? @relation(fields: [tenantId], references: [id])
|
|
343
|
-
|
|
344
|
-
@@index([machineId, timestamp])
|
|
345
|
-
@@index([formulaId])
|
|
346
|
-
@@map("machine_formula_result")
|
|
347
|
-
}
|
|
348
|
-
|
|
349
313
|
model Node {
|
|
350
314
|
id String @id @default(cuid())
|
|
351
315
|
positionAbsoluteX Int
|
|
@@ -353,12 +317,12 @@ model Node {
|
|
|
353
317
|
type NodeType
|
|
354
318
|
flowId String
|
|
355
319
|
productId String?
|
|
356
|
-
tenantId String
|
|
320
|
+
tenantId String
|
|
357
321
|
inputOf Edge[] @relation("inputNode")
|
|
358
322
|
outputOf Edge[] @relation("outputNode")
|
|
359
323
|
flow Flow @relation(fields: [flowId], references: [id], onDelete: Cascade)
|
|
360
324
|
product Product? @relation(fields: [productId], references: [id])
|
|
361
|
-
tenant Tenant
|
|
325
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
362
326
|
nodeOperationQueue NodeOperationQueue[]
|
|
363
327
|
operation Operation?
|
|
364
328
|
productionNode ProductionNode?
|
|
@@ -374,9 +338,9 @@ model Notification {
|
|
|
374
338
|
type String
|
|
375
339
|
createdAt DateTime @default(now())
|
|
376
340
|
downtimeEventId String?
|
|
377
|
-
tenantId String
|
|
341
|
+
tenantId String
|
|
378
342
|
downtimeEvent DowntimeEvent? @relation(fields: [downtimeEventId], references: [id])
|
|
379
|
-
tenant Tenant
|
|
343
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
380
344
|
NotificationToUser NotificationToUser[]
|
|
381
345
|
|
|
382
346
|
@@map("notification")
|
|
@@ -386,9 +350,9 @@ model NotificationToUser {
|
|
|
386
350
|
notificationId String
|
|
387
351
|
userId String
|
|
388
352
|
isRead Boolean @default(false)
|
|
389
|
-
tenantId String
|
|
353
|
+
tenantId String
|
|
390
354
|
notification Notification @relation(fields: [notificationId], references: [id])
|
|
391
|
-
tenant Tenant
|
|
355
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
392
356
|
user User @relation(fields: [userId], references: [id])
|
|
393
357
|
|
|
394
358
|
@@id([notificationId, userId])
|
|
@@ -410,14 +374,14 @@ model Operation {
|
|
|
410
374
|
engineeringTime Int @default(0)
|
|
411
375
|
initialTime Int @default(0)
|
|
412
376
|
pcpTime Int @default(0)
|
|
413
|
-
tenantId String
|
|
377
|
+
tenantId String
|
|
414
378
|
downtimeEvents DowntimeEvent[]
|
|
415
379
|
inputRegisters InputRegister[]
|
|
416
380
|
itemsHandlingRegisters ItemsHandlingRegister[]
|
|
417
381
|
nodeOperationQueue NodeOperationQueue[]
|
|
418
382
|
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
|
|
419
383
|
resource Resource @relation(fields: [resourceId], references: [id])
|
|
420
|
-
tenant Tenant
|
|
384
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
421
385
|
operationRegisters OperationRegister[]
|
|
422
386
|
inputOf OperationToOperation[] @relation("inputOperation")
|
|
423
387
|
outputOf OperationToOperation[] @relation("outputOperation")
|
|
@@ -444,10 +408,10 @@ model OperationGroup {
|
|
|
444
408
|
numberOfCuts Int @default(0)
|
|
445
409
|
flowId String
|
|
446
410
|
isDeleted Boolean @default(false)
|
|
447
|
-
tenantId String
|
|
411
|
+
tenantId String
|
|
448
412
|
downtimeEvents DowntimeEvent[]
|
|
449
413
|
flow Flow @relation(fields: [flowId], references: [id])
|
|
450
|
-
tenant Tenant
|
|
414
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
451
415
|
operationRegisters OperationRegister[]
|
|
452
416
|
productionNodes ProductionNode[]
|
|
453
417
|
operations Operation[] @relation("OperationToOperationGroup")
|
|
@@ -486,7 +450,7 @@ model OperationRegister {
|
|
|
486
450
|
endTime DateTime? @db.Timestamp(6)
|
|
487
451
|
elapsedTime BigInt?
|
|
488
452
|
productionNodeId String?
|
|
489
|
-
tenantId String
|
|
453
|
+
tenantId String
|
|
490
454
|
quantity Int @default(1)
|
|
491
455
|
timeSinceLastOperation BigInt?
|
|
492
456
|
timeToProduceSnapshot Int?
|
|
@@ -496,7 +460,7 @@ model OperationRegister {
|
|
|
496
460
|
operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
497
461
|
productionNode ProductionNode? @relation(fields: [productionNodeId], references: [id])
|
|
498
462
|
productionOrder ProductionOrder @relation(fields: [productionOrderId], references: [id])
|
|
499
|
-
tenant Tenant
|
|
463
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
500
464
|
|
|
501
465
|
@@index([operatorId, endTime, elapsedTime])
|
|
502
466
|
@@index([tenantId, operatorId, endTime])
|
|
@@ -511,10 +475,10 @@ model OperationToOperation {
|
|
|
511
475
|
amount Int
|
|
512
476
|
inputOperationId String
|
|
513
477
|
outputOperationId String
|
|
514
|
-
tenantId String
|
|
478
|
+
tenantId String
|
|
515
479
|
inputOperation Operation @relation("inputOperation", fields: [inputOperationId], references: [id], onDelete: Cascade)
|
|
516
480
|
outputOperation Operation @relation("outputOperation", fields: [outputOperationId], references: [id], onDelete: Cascade)
|
|
517
|
-
tenant Tenant
|
|
481
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
518
482
|
|
|
519
483
|
@@id([inputOperationId, outputOperationId])
|
|
520
484
|
@@map("operation_to_operation")
|
|
@@ -522,7 +486,7 @@ model OperationToOperation {
|
|
|
522
486
|
|
|
523
487
|
model Operator {
|
|
524
488
|
id String @id @default(cuid())
|
|
525
|
-
name String
|
|
489
|
+
name String
|
|
526
490
|
nickname String?
|
|
527
491
|
birthDate DateTime? @db.Date
|
|
528
492
|
phoneNumber String?
|
|
@@ -531,12 +495,12 @@ model Operator {
|
|
|
531
495
|
operatorRoleId String?
|
|
532
496
|
pin String?
|
|
533
497
|
isDeleted Boolean @default(false)
|
|
534
|
-
tenantId String
|
|
498
|
+
tenantId String
|
|
535
499
|
deviceOperators DeviceOperator[]
|
|
536
500
|
downtimeEvents DowntimeEvent[]
|
|
537
501
|
operationRegisters OperationRegister[]
|
|
538
502
|
operatorRole OperatorRole? @relation(fields: [operatorRoleId], references: [id])
|
|
539
|
-
tenant Tenant
|
|
503
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
540
504
|
ProductionNode ProductionNode?
|
|
541
505
|
habilityResources Resource[] @relation("OperatorToResource")
|
|
542
506
|
shiftId String?
|
|
@@ -545,6 +509,7 @@ model Operator {
|
|
|
545
509
|
operatorAvailability OperatorAvailabilityCache[]
|
|
546
510
|
qualityRegisters QualityRegister[]
|
|
547
511
|
|
|
512
|
+
@@unique([tenantId, name])
|
|
548
513
|
@@index([tenantId, isDeleted])
|
|
549
514
|
@@map("operator")
|
|
550
515
|
}
|
|
@@ -553,9 +518,9 @@ model OperatorRole {
|
|
|
553
518
|
id String @id @default(cuid())
|
|
554
519
|
name String
|
|
555
520
|
isDeleted Boolean @default(false)
|
|
556
|
-
tenantId String
|
|
521
|
+
tenantId String
|
|
557
522
|
operators Operator[]
|
|
558
|
-
tenant Tenant
|
|
523
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
559
524
|
|
|
560
525
|
@@map("operator_role")
|
|
561
526
|
}
|
|
@@ -564,8 +529,8 @@ model Panel {
|
|
|
564
529
|
id String @id @default(cuid())
|
|
565
530
|
title String
|
|
566
531
|
userId String @map("user_id")
|
|
567
|
-
tenantId String
|
|
568
|
-
tenant Tenant
|
|
532
|
+
tenantId String
|
|
533
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
569
534
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
570
535
|
reports Report[] @relation("PanelToReport")
|
|
571
536
|
|
|
@@ -583,12 +548,13 @@ model PasswordResetToken {
|
|
|
583
548
|
}
|
|
584
549
|
|
|
585
550
|
model Permission {
|
|
586
|
-
id
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
551
|
+
id String @id @default(cuid())
|
|
552
|
+
action String // Ex: "create", "read", "update", "delete", "manage"
|
|
553
|
+
subject String // Ex: "User", "Report", "all"
|
|
554
|
+
conditions Json? // Ex: {"tenantId": "123"}
|
|
555
|
+
description String?
|
|
590
556
|
|
|
591
|
-
|
|
557
|
+
roles RolePermission[]
|
|
592
558
|
}
|
|
593
559
|
|
|
594
560
|
model Product {
|
|
@@ -596,7 +562,7 @@ model Product {
|
|
|
596
562
|
name String
|
|
597
563
|
isLocal Boolean?
|
|
598
564
|
isDeleted Boolean @default(false)
|
|
599
|
-
tenantId String
|
|
565
|
+
tenantId String
|
|
600
566
|
customerProductId String?
|
|
601
567
|
description String?
|
|
602
568
|
sku String?
|
|
@@ -608,7 +574,7 @@ model Product {
|
|
|
608
574
|
flows Flow[]
|
|
609
575
|
itemsHandlingRegisters ItemsHandlingRegister[]
|
|
610
576
|
node Node[]
|
|
611
|
-
tenant Tenant
|
|
577
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
612
578
|
batches ProductBatch[]
|
|
613
579
|
composedBy ProductComponents[] @relation("componentOf")
|
|
614
580
|
componentOf ProductComponents[] @relation("composedBy")
|
|
@@ -624,10 +590,10 @@ model ProductComponents {
|
|
|
624
590
|
composedById String
|
|
625
591
|
componentOfId String
|
|
626
592
|
quantity Float
|
|
627
|
-
tenantId String
|
|
593
|
+
tenantId String
|
|
628
594
|
componentOf Product @relation("componentOf", fields: [componentOfId], references: [id], onDelete: Cascade)
|
|
629
595
|
composedBy Product @relation("composedBy", fields: [composedById], references: [id], onDelete: Cascade)
|
|
630
|
-
tenant Tenant
|
|
596
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
631
597
|
|
|
632
598
|
@@id([componentOfId, composedById])
|
|
633
599
|
@@map("product_components")
|
|
@@ -641,7 +607,7 @@ model ProductionNode {
|
|
|
641
607
|
operationId String?
|
|
642
608
|
operationGroupId Int?
|
|
643
609
|
productionOrderId String?
|
|
644
|
-
tenantId String
|
|
610
|
+
tenantId String
|
|
645
611
|
operationRegister OperationRegister[]
|
|
646
612
|
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
647
613
|
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
|
|
@@ -649,7 +615,7 @@ model ProductionNode {
|
|
|
649
615
|
operation Operation? @relation(fields: [operationId], references: [id])
|
|
650
616
|
operator Operator? @relation(fields: [operatorId], references: [id])
|
|
651
617
|
productionOrder ProductionOrder? @relation(fields: [productionOrderId], references: [id])
|
|
652
|
-
tenant Tenant
|
|
618
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
653
619
|
|
|
654
620
|
@@map("production_node")
|
|
655
621
|
}
|
|
@@ -658,13 +624,13 @@ model ProductionOrder {
|
|
|
658
624
|
id String @id @default(cuid())
|
|
659
625
|
productId String
|
|
660
626
|
flowId String?
|
|
661
|
-
productionOrderIndex Int?
|
|
627
|
+
productionOrderIndex Int?
|
|
662
628
|
batchSize Float
|
|
663
629
|
hasStarted Boolean @default(false)
|
|
664
630
|
isRunning Boolean @default(false)
|
|
665
631
|
isFinished Boolean @default(false)
|
|
666
632
|
sectorAggregatedValue Float?
|
|
667
|
-
tenantId String
|
|
633
|
+
tenantId String
|
|
668
634
|
endDate DateTime? @db.Date
|
|
669
635
|
expectedEndDate DateTime? @db.Date
|
|
670
636
|
startDate DateTime? @db.Date
|
|
@@ -678,8 +644,9 @@ model ProductionOrder {
|
|
|
678
644
|
qualityRegisters QualityRegister[]
|
|
679
645
|
flow Flow? @relation(fields: [flowId], references: [id])
|
|
680
646
|
Product Product @relation(fields: [productId], references: [id])
|
|
681
|
-
tenant Tenant
|
|
647
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
682
648
|
|
|
649
|
+
@@unique([tenantId, productionOrderIndex])
|
|
683
650
|
@@index([tenantId, isFinished])
|
|
684
651
|
@@index([productId])
|
|
685
652
|
@@index([flowId])
|
|
@@ -690,10 +657,10 @@ model ProductToOperation {
|
|
|
690
657
|
amount Int
|
|
691
658
|
productId String
|
|
692
659
|
operationId String
|
|
693
|
-
tenantId String
|
|
660
|
+
tenantId String
|
|
694
661
|
operation Operation @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
695
662
|
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
696
|
-
tenant Tenant
|
|
663
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
697
664
|
|
|
698
665
|
@@id([productId, operationId])
|
|
699
666
|
@@map("product_to_operation")
|
|
@@ -706,8 +673,8 @@ model Report {
|
|
|
706
673
|
data String
|
|
707
674
|
createdAt DateTime @default(now())
|
|
708
675
|
updatedAt DateTime? @updatedAt
|
|
709
|
-
tenantId String
|
|
710
|
-
tenant Tenant
|
|
676
|
+
tenantId String
|
|
677
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
711
678
|
panels Panel[] @relation("PanelToReport")
|
|
712
679
|
|
|
713
680
|
@@map("report")
|
|
@@ -715,30 +682,55 @@ model Report {
|
|
|
715
682
|
|
|
716
683
|
model Resource {
|
|
717
684
|
id String @id @default(cuid())
|
|
718
|
-
name String
|
|
685
|
+
name String
|
|
719
686
|
resourceType ResourceType
|
|
720
687
|
description String?
|
|
721
|
-
tenantId String
|
|
688
|
+
tenantId String
|
|
722
689
|
Operation Operation[]
|
|
723
|
-
tenant Tenant
|
|
690
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
724
691
|
machines Machine[] @relation("MachineToResource")
|
|
725
692
|
operators Operator[] @relation("OperatorToResource")
|
|
726
693
|
|
|
694
|
+
@@unique([tenantId, name])
|
|
727
695
|
@@map("resource")
|
|
728
696
|
}
|
|
729
697
|
|
|
698
|
+
model Role {
|
|
699
|
+
id String @id @default(cuid())
|
|
700
|
+
name String // Ex: "Admin", "Operador", "Gerente"
|
|
701
|
+
description String?
|
|
702
|
+
tenantId String
|
|
703
|
+
permissions RolePermission[]
|
|
704
|
+
users User[]
|
|
705
|
+
|
|
706
|
+
tenant Tenant @relation(fields: [tenantId], references: [id])
|
|
707
|
+
|
|
708
|
+
@@unique([name, tenantId])
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
model RolePermission {
|
|
712
|
+
roleId String
|
|
713
|
+
permissionId String
|
|
714
|
+
|
|
715
|
+
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
|
716
|
+
permission Permission @relation(fields: [permissionId], references: [id], onDelete: Cascade)
|
|
717
|
+
|
|
718
|
+
@@id([roleId, permissionId])
|
|
719
|
+
}
|
|
720
|
+
|
|
730
721
|
model Sector {
|
|
731
722
|
id String @id @default(cuid())
|
|
732
|
-
name String @
|
|
723
|
+
name String @db.VarChar(100)
|
|
733
724
|
description String? @db.VarChar(255)
|
|
734
725
|
isDeleted Boolean @default(false)
|
|
735
|
-
tenantId String
|
|
726
|
+
tenantId String
|
|
736
727
|
stationFrom ItemsHandlingRegister[] @relation("sectorFrom")
|
|
737
728
|
stationTo ItemsHandlingRegister[] @relation("sectorTo")
|
|
738
729
|
machines Machine[]
|
|
739
|
-
tenant Tenant
|
|
730
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
740
731
|
qualityRegisters QualityRegister[]
|
|
741
732
|
|
|
733
|
+
@@unique([tenantId, name])
|
|
742
734
|
@@map("sector")
|
|
743
735
|
}
|
|
744
736
|
|
|
@@ -749,8 +741,8 @@ model SewMachineRawData {
|
|
|
749
741
|
stitches_count Int
|
|
750
742
|
line_cut Boolean @default(false)
|
|
751
743
|
machine_id String?
|
|
752
|
-
tenantId String
|
|
753
|
-
tenant Tenant
|
|
744
|
+
tenantId String
|
|
745
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
754
746
|
|
|
755
747
|
@@index([machine_id, start_timestamp])
|
|
756
748
|
@@map("sew_machine_raw_data")
|
|
@@ -758,13 +750,14 @@ model SewMachineRawData {
|
|
|
758
750
|
|
|
759
751
|
model Shift {
|
|
760
752
|
id String @id @default(cuid())
|
|
761
|
-
name String @
|
|
762
|
-
tenantId String
|
|
753
|
+
name String @db.VarChar(100)
|
|
754
|
+
tenantId String
|
|
763
755
|
days ShiftDay[]
|
|
764
|
-
tenant Tenant
|
|
756
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
765
757
|
operators Operator[]
|
|
766
758
|
operatorAvailability OperatorAvailabilityCache[]
|
|
767
759
|
|
|
760
|
+
@@unique([tenantId, name])
|
|
768
761
|
@@map("shift")
|
|
769
762
|
}
|
|
770
763
|
|
|
@@ -777,24 +770,24 @@ model ShiftDay {
|
|
|
777
770
|
shiftId String
|
|
778
771
|
shift Shift @relation(fields: [shiftId], references: [id], onDelete: Cascade)
|
|
779
772
|
breaks Break[]
|
|
780
|
-
tenantId String
|
|
781
|
-
tenant Tenant
|
|
773
|
+
tenantId String
|
|
774
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
782
775
|
|
|
783
776
|
@@unique([shiftId, dayOfWeek])
|
|
784
777
|
@@map("shift_day")
|
|
785
778
|
}
|
|
786
779
|
|
|
787
780
|
model SystemPreferences {
|
|
788
|
-
id Int
|
|
789
|
-
downtimeEventTime Int
|
|
790
|
-
notificationTime Int
|
|
791
|
-
lowPercentageColor Colors
|
|
792
|
-
averagePercentageColor Colors
|
|
793
|
-
highPercentageColor Colors
|
|
794
|
-
averagePercentageValue Float
|
|
795
|
-
highPercentageValue Float
|
|
796
|
-
tenantId String
|
|
797
|
-
tenant Tenant
|
|
781
|
+
id Int @id @default(autoincrement())
|
|
782
|
+
downtimeEventTime Int @default(300)
|
|
783
|
+
notificationTime Int @default(10)
|
|
784
|
+
lowPercentageColor Colors @default(red)
|
|
785
|
+
averagePercentageColor Colors @default(yellow)
|
|
786
|
+
highPercentageColor Colors @default(green)
|
|
787
|
+
averagePercentageValue Float @default(50)
|
|
788
|
+
highPercentageValue Float @default(80)
|
|
789
|
+
tenantId String
|
|
790
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
798
791
|
|
|
799
792
|
@@map("system_preferences")
|
|
800
793
|
}
|
|
@@ -820,37 +813,25 @@ model TwoFactorToken {
|
|
|
820
813
|
model User {
|
|
821
814
|
id String @id @default(uuid())
|
|
822
815
|
name String
|
|
823
|
-
email String
|
|
816
|
+
email String
|
|
824
817
|
emailVerified DateTime?
|
|
825
818
|
image String?
|
|
826
819
|
password String
|
|
827
820
|
isTwoFactorEnabled Boolean @default(false)
|
|
828
|
-
|
|
829
|
-
|
|
821
|
+
roleId String?
|
|
822
|
+
role Role? @relation(fields: [roleId], references: [id])
|
|
823
|
+
tenantId String
|
|
830
824
|
accounts Account[]
|
|
831
825
|
follows Follower[]
|
|
832
826
|
NotificationToUser NotificationToUser[]
|
|
833
827
|
Panel Panel[]
|
|
834
828
|
twoFactorConfirmation TwoFactorConfirmation?
|
|
835
|
-
tenant Tenant
|
|
836
|
-
userPermissions UserPermission[]
|
|
837
|
-
aiConversations AiConversation[]
|
|
829
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
838
830
|
|
|
831
|
+
@@unique([tenantId, email])
|
|
839
832
|
@@map("user")
|
|
840
833
|
}
|
|
841
834
|
|
|
842
|
-
model UserPermission {
|
|
843
|
-
id Int @id @default(autoincrement())
|
|
844
|
-
userId String @map("user_id")
|
|
845
|
-
permission_id Int?
|
|
846
|
-
tenantId String?
|
|
847
|
-
permission Permission? @relation(fields: [permission_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_permission")
|
|
848
|
-
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
849
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
850
|
-
|
|
851
|
-
@@map("user_permission")
|
|
852
|
-
}
|
|
853
|
-
|
|
854
835
|
view ProductivityInterval {
|
|
855
836
|
machineId String
|
|
856
837
|
sequenceId Int @map("sequence_id")
|
|
@@ -865,7 +846,7 @@ view ProductivityInterval {
|
|
|
865
846
|
efficiencyPercentage Float? @map("efficiency_percentage")
|
|
866
847
|
timeToProduceSnapshot Int? @map("time_to_produce_snapshot")
|
|
867
848
|
downtimeSeconds Float? @map("downtime_seconds")
|
|
868
|
-
tenantId String
|
|
849
|
+
tenantId String
|
|
869
850
|
|
|
870
851
|
@@unique([machineId, sequenceId])
|
|
871
852
|
@@map("productivity_intervals")
|
|
@@ -889,13 +870,13 @@ model NodeOperationQueue {
|
|
|
889
870
|
createdAt DateTime @default(now())
|
|
890
871
|
updatedAt DateTime @updatedAt
|
|
891
872
|
productionOrderId String
|
|
892
|
-
tenantId String
|
|
873
|
+
tenantId String
|
|
893
874
|
deviceId String?
|
|
894
875
|
device Device? @relation(fields: [deviceId], references: [id], onDelete: Cascade)
|
|
895
876
|
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
|
|
896
877
|
operation Operation @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
897
878
|
productionOrder ProductionOrder @relation(fields: [productionOrderId], references: [id], onDelete: Cascade)
|
|
898
|
-
tenant Tenant
|
|
879
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
899
880
|
|
|
900
881
|
@@map("node_operation_queue")
|
|
901
882
|
}
|
|
@@ -935,11 +916,11 @@ model MachineSensors {
|
|
|
935
916
|
sensor2Name String?
|
|
936
917
|
sensor1Show Boolean @default(true)
|
|
937
918
|
sensor2Show Boolean @default(true)
|
|
938
|
-
tenantId String
|
|
919
|
+
tenantId String
|
|
939
920
|
sensor1Multiplier Float?
|
|
940
921
|
sensor2Multiplier Float?
|
|
941
922
|
machine Machine @relation(fields: [machineId], references: [id])
|
|
942
|
-
tenant Tenant
|
|
923
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
943
924
|
|
|
944
925
|
@@index([machineId], map: "idx_machine_sensors_machine_id")
|
|
945
926
|
@@map("machine_sensors")
|
|
@@ -1004,11 +985,11 @@ model ProductBatch {
|
|
|
1004
985
|
expiryDate DateTime @db.Date
|
|
1005
986
|
createdAt DateTime @default(now())
|
|
1006
987
|
updatedAt DateTime @updatedAt
|
|
1007
|
-
tenantId String
|
|
988
|
+
tenantId String
|
|
1008
989
|
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
1009
|
-
tenant Tenant
|
|
990
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1010
991
|
|
|
1011
|
-
@@unique([productId, batchNumber, internalBatchNumber])
|
|
992
|
+
@@unique([tenantId, productId, batchNumber, internalBatchNumber])
|
|
1012
993
|
@@map("product_batch")
|
|
1013
994
|
}
|
|
1014
995
|
|
|
@@ -1050,11 +1031,11 @@ model MachineOperationStitch {
|
|
|
1050
1031
|
machineId String
|
|
1051
1032
|
operationId String
|
|
1052
1033
|
stitches Int
|
|
1053
|
-
tenantId String
|
|
1034
|
+
tenantId String
|
|
1054
1035
|
|
|
1055
1036
|
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
1056
1037
|
operation Operation @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
1057
|
-
tenant Tenant
|
|
1038
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1058
1039
|
|
|
1059
1040
|
@@id([machineId, operationId])
|
|
1060
1041
|
@@map("machine_operation_stitch")
|
|
@@ -1062,7 +1043,7 @@ model MachineOperationStitch {
|
|
|
1062
1043
|
|
|
1063
1044
|
model ProductivityIntervalCache {
|
|
1064
1045
|
id String @id @default(cuid())
|
|
1065
|
-
tenantId String
|
|
1046
|
+
tenantId String
|
|
1066
1047
|
machineId String
|
|
1067
1048
|
operatorId String
|
|
1068
1049
|
operationId String?
|
|
@@ -1082,7 +1063,7 @@ model ProductivityIntervalCache {
|
|
|
1082
1063
|
|
|
1083
1064
|
createdAt DateTime @default(now())
|
|
1084
1065
|
|
|
1085
|
-
tenant Tenant
|
|
1066
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1086
1067
|
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
1087
1068
|
operator Operator @relation(fields: [operatorId], references: [id], onDelete: Cascade)
|
|
1088
1069
|
operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
@@ -1095,52 +1076,6 @@ model ProductivityIntervalCache {
|
|
|
1095
1076
|
@@map("productivity_interval_cache")
|
|
1096
1077
|
}
|
|
1097
1078
|
|
|
1098
|
-
// --- AI & I. Intelligence ---
|
|
1099
|
-
|
|
1100
|
-
model AiConversation {
|
|
1101
|
-
id String @id @default(cuid())
|
|
1102
|
-
userId String
|
|
1103
|
-
tenantId String?
|
|
1104
|
-
title String?
|
|
1105
|
-
messages AiMessage[]
|
|
1106
|
-
createdAt DateTime @default(now())
|
|
1107
|
-
updatedAt DateTime @updatedAt
|
|
1108
|
-
user User @relation(fields: [userId], references: [id])
|
|
1109
|
-
tenant Tenant? @relation(fields: [tenantId], references: [id])
|
|
1110
|
-
|
|
1111
|
-
@@index([userId])
|
|
1112
|
-
@@map("ai_conversation")
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
model AiMessage {
|
|
1116
|
-
id String @id @default(cuid())
|
|
1117
|
-
conversationId String
|
|
1118
|
-
role String // 'user' | 'assistant' | 'system' | 'data'
|
|
1119
|
-
content String // Markdown content
|
|
1120
|
-
sqlQuery String? // The generated SQL (if assistant)
|
|
1121
|
-
toolCalls Json? // If the AI called tools
|
|
1122
|
-
isCorrect Boolean? // Feedback: true=Good, false=Bad
|
|
1123
|
-
correction String? // User's textual correction or correct SQL
|
|
1124
|
-
createdAt DateTime @default(now())
|
|
1125
|
-
conversation AiConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
1126
|
-
|
|
1127
|
-
@@index([conversationId])
|
|
1128
|
-
@@map("ai_message")
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
model AiFeedback {
|
|
1132
|
-
id String @id @default(cuid())
|
|
1133
|
-
tenantId String?
|
|
1134
|
-
userId String
|
|
1135
|
-
question String
|
|
1136
|
-
generatedSql String
|
|
1137
|
-
correctedSql String?
|
|
1138
|
-
comment String?
|
|
1139
|
-
createdAt DateTime @default(now())
|
|
1140
|
-
|
|
1141
|
-
@@map("ai_feedback")
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
1079
|
model QualityRegister {
|
|
1145
1080
|
id String @id @default(cuid())
|
|
1146
1081
|
timestamp DateTime @default(now())
|
|
@@ -1151,14 +1086,14 @@ model QualityRegister {
|
|
|
1151
1086
|
qualityIssueId String?
|
|
1152
1087
|
amount Int @default(1)
|
|
1153
1088
|
comments String?
|
|
1154
|
-
tenantId String
|
|
1089
|
+
tenantId String
|
|
1155
1090
|
|
|
1156
1091
|
operation Operation @relation(fields: [operationId], references: [id])
|
|
1157
1092
|
productionOrder ProductionOrder? @relation(fields: [productionOrderId], references: [id])
|
|
1158
1093
|
operator Operator? @relation(fields: [operatorId], references: [id])
|
|
1159
1094
|
sector Sector? @relation(fields: [sectorId], references: [id])
|
|
1160
1095
|
qualityIssue QualityIssue? @relation(fields: [qualityIssueId], references: [id])
|
|
1161
|
-
tenant Tenant
|
|
1096
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1162
1097
|
|
|
1163
1098
|
@@index([tenantId])
|
|
1164
1099
|
@@index([operationId])
|
|
@@ -1174,10 +1109,10 @@ model QualityIssue {
|
|
|
1174
1109
|
description String?
|
|
1175
1110
|
category QualityIssueCategory @default(OTHER)
|
|
1176
1111
|
isDeleted Boolean @default(false)
|
|
1177
|
-
tenantId String
|
|
1112
|
+
tenantId String
|
|
1178
1113
|
|
|
1179
1114
|
qualityRegisters QualityRegister[]
|
|
1180
|
-
tenant Tenant
|
|
1115
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1181
1116
|
|
|
1182
1117
|
@@index([tenantId])
|
|
1183
1118
|
@@map("quality_issue")
|
|
@@ -1197,7 +1132,7 @@ model OperatorAvailabilityCache {
|
|
|
1197
1132
|
|
|
1198
1133
|
operatorId String
|
|
1199
1134
|
shiftId String? // Pode ser nulo se o operador não estava atrelado a turno no dia, mas trabalhou
|
|
1200
|
-
tenantId String
|
|
1135
|
+
tenantId String
|
|
1201
1136
|
|
|
1202
1137
|
// Tempos esperados (baseados na configuração de ShiftDay / Break)
|
|
1203
1138
|
expectedGrossMinutes Int @default(0) // Tempo total de turno configurado (end_time - start_time)
|
|
@@ -1215,7 +1150,7 @@ model OperatorAvailabilityCache {
|
|
|
1215
1150
|
|
|
1216
1151
|
operator Operator @relation(fields: [operatorId], references: [id], onDelete: Cascade)
|
|
1217
1152
|
shift Shift? @relation(fields: [shiftId], references: [id], onDelete: SetNull)
|
|
1218
|
-
tenant Tenant
|
|
1153
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
1219
1154
|
|
|
1220
1155
|
@@unique([operatorId, date]) // Garante que há apenas 1 registro de fechamento por operador por dia
|
|
1221
1156
|
@@index([tenantId, date])
|