@juliobrim/prisma-shared 1.0.6
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/README.md +250 -0
- package/migrations/20250901163244_baseline_migration/migration.sql +963 -0
- package/migrations/20250901164001_operation_register_quantity/migration.sql +2 -0
- package/migrations/20250901214352_add_iot_message_register_table/migration.sql +20 -0
- package/migrations/20250902003109_add_machine_relation/migration.sql +11 -0
- package/migrations/migration_lock.toml +3 -0
- package/package.json +53 -0
- package/schema.prisma +742 -0
package/schema.prisma
ADDED
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
generator client {
|
|
2
|
+
provider = "prisma-client-js"
|
|
3
|
+
output = "../node_modules/.prisma/client"
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
datasource db {
|
|
7
|
+
provider = "postgresql"
|
|
8
|
+
url = env("DATABASE_URL")
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
model Tenant {
|
|
12
|
+
id String @id @default(cuid())
|
|
13
|
+
name String @unique
|
|
14
|
+
slug String @unique
|
|
15
|
+
domain String? @unique
|
|
16
|
+
isActive Boolean @default(true)
|
|
17
|
+
createdAt DateTime @default(now())
|
|
18
|
+
updatedAt DateTime @updatedAt
|
|
19
|
+
accounts Account[]
|
|
20
|
+
breaks Break[]
|
|
21
|
+
downtimeEvents DowntimeEvent[]
|
|
22
|
+
downtimeReasons DowntimeReason[]
|
|
23
|
+
edges Edge[]
|
|
24
|
+
flows Flow[]
|
|
25
|
+
followers Follower[]
|
|
26
|
+
inputRegisters InputRegister[]
|
|
27
|
+
itemsHandlingRegisters ItemsHandlingRegister[]
|
|
28
|
+
machines Machine[]
|
|
29
|
+
nodes Node[]
|
|
30
|
+
nodeOperationQueue NodeOperationQueue[]
|
|
31
|
+
notifications Notification[]
|
|
32
|
+
notificationToUsers NotificationToUser[]
|
|
33
|
+
operations Operation[]
|
|
34
|
+
operationGroups OperationGroup[]
|
|
35
|
+
operationRegisters OperationRegister[]
|
|
36
|
+
operationToOperations OperationToOperation[]
|
|
37
|
+
operators Operator[]
|
|
38
|
+
operatorRoles OperatorRole[]
|
|
39
|
+
panels Panel[]
|
|
40
|
+
products Product[]
|
|
41
|
+
productComponents ProductComponents[]
|
|
42
|
+
productToOperations ProductToOperation[]
|
|
43
|
+
productionNodes ProductionNode[]
|
|
44
|
+
productionOrders ProductionOrder[]
|
|
45
|
+
reports Report[]
|
|
46
|
+
resources Resource[]
|
|
47
|
+
sectors Sector[]
|
|
48
|
+
sewMachineRawData SewMachineRawData[]
|
|
49
|
+
shifts Shift[]
|
|
50
|
+
systemPreferences SystemPreferences[]
|
|
51
|
+
users User[]
|
|
52
|
+
userPermissions UserPermission[]
|
|
53
|
+
userShifts UserShift[]
|
|
54
|
+
IotMessageRegister IotMessageRegister[]
|
|
55
|
+
|
|
56
|
+
@@map("tenant")
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
model Account {
|
|
60
|
+
id String @id @default(cuid())
|
|
61
|
+
userId String @map("user_id")
|
|
62
|
+
type String
|
|
63
|
+
provider String
|
|
64
|
+
providerAccountId String @map("provider_account_id")
|
|
65
|
+
refresh_token String?
|
|
66
|
+
access_token String?
|
|
67
|
+
expires_at Int?
|
|
68
|
+
token_type String?
|
|
69
|
+
scope String?
|
|
70
|
+
id_token String?
|
|
71
|
+
session_state String?
|
|
72
|
+
oauth_token_secret String?
|
|
73
|
+
oauth_token String?
|
|
74
|
+
tenantId String?
|
|
75
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
76
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
77
|
+
|
|
78
|
+
@@unique([provider, providerAccountId])
|
|
79
|
+
@@map("account")
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
model Break {
|
|
83
|
+
id String @id @default(cuid())
|
|
84
|
+
start_time DateTime @db.Time(6)
|
|
85
|
+
end_time DateTime @db.Time(6)
|
|
86
|
+
shiftId String
|
|
87
|
+
tenantId String?
|
|
88
|
+
shift Shift @relation(fields: [shiftId], references: [id])
|
|
89
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
90
|
+
|
|
91
|
+
@@map("break")
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
model DowntimeEvent {
|
|
95
|
+
id String @id @default(cuid())
|
|
96
|
+
start_time DateTime @default(now())
|
|
97
|
+
downtimeReasonId String?
|
|
98
|
+
machine_id String
|
|
99
|
+
operatorId String?
|
|
100
|
+
operationId String?
|
|
101
|
+
operationGroupId Int?
|
|
102
|
+
end_time DateTime?
|
|
103
|
+
elapsedTime BigInt?
|
|
104
|
+
isJustified Boolean @default(false)
|
|
105
|
+
tenantId String?
|
|
106
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
107
|
+
downtimeReason DowntimeReason? @relation(fields: [downtimeReasonId], references: [id], onUpdate: NoAction, map: "fk_downtimeReason")
|
|
108
|
+
machine Machine @relation(fields: [machine_id], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "fk_machine")
|
|
109
|
+
operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade, map: "fk_operation")
|
|
110
|
+
operationGroup OperationGroup? @relation(fields: [operationGroupId], references: [id], onDelete: Cascade, map: "fk_operation_group")
|
|
111
|
+
operator Operator? @relation(fields: [operatorId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "fk_operator")
|
|
112
|
+
Notification Notification[]
|
|
113
|
+
|
|
114
|
+
@@map("downtime_event")
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
model DowntimeReason {
|
|
118
|
+
id String @id @default(cuid())
|
|
119
|
+
name String @unique @db.VarChar(100)
|
|
120
|
+
description String? @db.VarChar(255)
|
|
121
|
+
isImpactful Boolean @default(false)
|
|
122
|
+
isDeleted Boolean @default(false)
|
|
123
|
+
tenantId String?
|
|
124
|
+
downtime DowntimeEvent[]
|
|
125
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
126
|
+
|
|
127
|
+
@@map("downtime_reason")
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
model Edge {
|
|
131
|
+
amount Int
|
|
132
|
+
inputNodeId String
|
|
133
|
+
outputNodeId String
|
|
134
|
+
tenantId String?
|
|
135
|
+
inputNode Node @relation("inputNode", fields: [inputNodeId], references: [id], onDelete: Cascade)
|
|
136
|
+
outputNode Node @relation("outputNode", fields: [outputNodeId], references: [id], onDelete: Cascade)
|
|
137
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
138
|
+
|
|
139
|
+
@@id([inputNodeId, outputNodeId])
|
|
140
|
+
@@map("edge")
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
model Flow {
|
|
144
|
+
id String @id @default(cuid())
|
|
145
|
+
title String
|
|
146
|
+
productId String?
|
|
147
|
+
isDeleted Boolean @default(false)
|
|
148
|
+
tenantId String?
|
|
149
|
+
product Product? @relation(fields: [productId], references: [id])
|
|
150
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
151
|
+
nodes Node[]
|
|
152
|
+
operationGroups OperationGroup[]
|
|
153
|
+
productionOrders ProductionOrder[]
|
|
154
|
+
|
|
155
|
+
@@map("flow")
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
model Follower {
|
|
159
|
+
userId String
|
|
160
|
+
machineId String
|
|
161
|
+
tenantId String?
|
|
162
|
+
machine Machine @relation(fields: [machineId], references: [id])
|
|
163
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
164
|
+
user User @relation(fields: [userId], references: [id])
|
|
165
|
+
|
|
166
|
+
@@id([userId, machineId])
|
|
167
|
+
@@map("follower")
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
model InputRegister {
|
|
171
|
+
id Int @id @default(autoincrement())
|
|
172
|
+
in1Count BigInt @map("in1_count")
|
|
173
|
+
in2Count BigInt @map("in2_count")
|
|
174
|
+
in3Count BigInt @map("in3_count")
|
|
175
|
+
in4Count BigInt @map("in4_count")
|
|
176
|
+
timestamp DateTime @default(now())
|
|
177
|
+
machineId String
|
|
178
|
+
tenantId String?
|
|
179
|
+
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
180
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
181
|
+
|
|
182
|
+
@@map("input_register")
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
model IotMessageRegister {
|
|
186
|
+
id Int @id @default(autoincrement())
|
|
187
|
+
timestamp DateTime @default(now()) @db.Timestamp(6)
|
|
188
|
+
di1 Int
|
|
189
|
+
di2 Int
|
|
190
|
+
di3 Int
|
|
191
|
+
di4 Int
|
|
192
|
+
di1State Boolean @map("di1_state")
|
|
193
|
+
di2State Boolean @map("di2_state")
|
|
194
|
+
di3State Boolean @map("di3_state")
|
|
195
|
+
di4State Boolean @map("di4_state")
|
|
196
|
+
machineId String
|
|
197
|
+
tenantId String?
|
|
198
|
+
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
199
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
200
|
+
|
|
201
|
+
@@map("iot_message_register")
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
model ItemsHandlingRegister {
|
|
205
|
+
id Int @id @default(autoincrement())
|
|
206
|
+
operationId String?
|
|
207
|
+
stationFromId String?
|
|
208
|
+
stationToId String?
|
|
209
|
+
productId String?
|
|
210
|
+
productionOrderId String
|
|
211
|
+
amount Int
|
|
212
|
+
sectorFromId String?
|
|
213
|
+
sectorToId String?
|
|
214
|
+
timestamp DateTime @default(now())
|
|
215
|
+
tenantId String?
|
|
216
|
+
operation Operation? @relation(fields: [operationId], references: [id])
|
|
217
|
+
product Product? @relation(fields: [productId], references: [id])
|
|
218
|
+
productionOrder ProductionOrder @relation(fields: [productionOrderId], references: [id])
|
|
219
|
+
sectorFrom Sector? @relation("sectorFrom", fields: [sectorFromId], references: [id])
|
|
220
|
+
sectorTo Sector? @relation("sectorTo", fields: [sectorToId], references: [id])
|
|
221
|
+
stationFrom Machine? @relation("stationFrom", fields: [stationFromId], references: [id])
|
|
222
|
+
stationTo Machine? @relation("stationTo", fields: [stationToId], references: [id])
|
|
223
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
224
|
+
|
|
225
|
+
@@map("items_handling_register")
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
model Machine {
|
|
229
|
+
id String @id @default(cuid())
|
|
230
|
+
model String? @db.VarChar(100)
|
|
231
|
+
name String @unique @db.VarChar(100)
|
|
232
|
+
capacity Float? @db.Real
|
|
233
|
+
clp_index String?
|
|
234
|
+
acquired_date DateTime? @db.Date
|
|
235
|
+
macAddress String? @db.VarChar(17)
|
|
236
|
+
isDeleted Boolean @default(false)
|
|
237
|
+
sectorId String?
|
|
238
|
+
tenantId String?
|
|
239
|
+
downtime DowntimeEvent[]
|
|
240
|
+
followers Follower[]
|
|
241
|
+
inputRegisters InputRegister[]
|
|
242
|
+
stationFrom ItemsHandlingRegister[] @relation("stationFrom")
|
|
243
|
+
stationTo ItemsHandlingRegister[] @relation("stationTo")
|
|
244
|
+
sector Sector? @relation(fields: [sectorId], references: [id])
|
|
245
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
246
|
+
operationRegister OperationRegister[]
|
|
247
|
+
productionNodes ProductionNode?
|
|
248
|
+
operationResources Resource[] @relation("MachineToResource")
|
|
249
|
+
IotMessageRegister IotMessageRegister[]
|
|
250
|
+
|
|
251
|
+
@@map("machine")
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
model Node {
|
|
255
|
+
id String @id @default(cuid())
|
|
256
|
+
positionAbsoluteX Int
|
|
257
|
+
positionAbsoluteY Int
|
|
258
|
+
type NodeType
|
|
259
|
+
flowId String
|
|
260
|
+
productId String?
|
|
261
|
+
tenantId String?
|
|
262
|
+
inputOf Edge[] @relation("inputNode")
|
|
263
|
+
outputOf Edge[] @relation("outputNode")
|
|
264
|
+
flow Flow @relation(fields: [flowId], references: [id], onDelete: Cascade)
|
|
265
|
+
product Product? @relation(fields: [productId], references: [id])
|
|
266
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
267
|
+
nodeOperationQueue NodeOperationQueue[]
|
|
268
|
+
operation Operation?
|
|
269
|
+
productionNode ProductionNode?
|
|
270
|
+
|
|
271
|
+
@@map("node")
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
model Notification {
|
|
275
|
+
id String @id @default(cuid())
|
|
276
|
+
title String
|
|
277
|
+
message String
|
|
278
|
+
type String
|
|
279
|
+
createdAt DateTime @default(now())
|
|
280
|
+
downtimeEventId String?
|
|
281
|
+
tenantId String?
|
|
282
|
+
downtimeEvent DowntimeEvent? @relation(fields: [downtimeEventId], references: [id])
|
|
283
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
284
|
+
NotificationToUser NotificationToUser[]
|
|
285
|
+
|
|
286
|
+
@@map("notification")
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
model NotificationToUser {
|
|
290
|
+
notificationId String
|
|
291
|
+
userId String
|
|
292
|
+
isRead Boolean @default(false)
|
|
293
|
+
tenantId String?
|
|
294
|
+
notification Notification @relation(fields: [notificationId], references: [id])
|
|
295
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
296
|
+
user User @relation(fields: [userId], references: [id])
|
|
297
|
+
|
|
298
|
+
@@id([notificationId, userId])
|
|
299
|
+
@@map("notification_to_user")
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
model Operation {
|
|
303
|
+
id String @id @default(cuid())
|
|
304
|
+
stitches Int
|
|
305
|
+
finalIntervalTime Float
|
|
306
|
+
description String
|
|
307
|
+
resourceId String
|
|
308
|
+
timeToProduce Int @default(10)
|
|
309
|
+
numberOfCuts Int @default(0)
|
|
310
|
+
nodeId String @unique
|
|
311
|
+
nodeIndex Int?
|
|
312
|
+
amount Int @default(1)
|
|
313
|
+
operationId String?
|
|
314
|
+
engineeringTime Int @default(0)
|
|
315
|
+
initialTime Int @default(0)
|
|
316
|
+
pcpTime Int @default(0)
|
|
317
|
+
tenantId String?
|
|
318
|
+
downtimeEvents DowntimeEvent[]
|
|
319
|
+
itemsHandlingRegisters ItemsHandlingRegister[]
|
|
320
|
+
nodeOperationQueue NodeOperationQueue[]
|
|
321
|
+
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
|
|
322
|
+
resource Resource @relation(fields: [resourceId], references: [id])
|
|
323
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
324
|
+
operationRegisters OperationRegister[]
|
|
325
|
+
inputOf OperationToOperation[] @relation("inputOperation")
|
|
326
|
+
outputOf OperationToOperation[] @relation("outputOperation")
|
|
327
|
+
products ProductToOperation[]
|
|
328
|
+
productionNodes ProductionNode[]
|
|
329
|
+
operationGroups OperationGroup[] @relation("OperationToOperationGroup")
|
|
330
|
+
|
|
331
|
+
@@map("operation")
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
model OperationGroup {
|
|
335
|
+
id Int @id @default(autoincrement())
|
|
336
|
+
name String
|
|
337
|
+
stitches Int @default(10)
|
|
338
|
+
finalIntervalTime Float
|
|
339
|
+
timeToProduce Int @default(10)
|
|
340
|
+
numberOfCuts Int @default(0)
|
|
341
|
+
flowId String
|
|
342
|
+
isDeleted Boolean @default(false)
|
|
343
|
+
tenantId String?
|
|
344
|
+
downtimeEvents DowntimeEvent[]
|
|
345
|
+
flow Flow @relation(fields: [flowId], references: [id])
|
|
346
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
347
|
+
operationRegisters OperationRegister[]
|
|
348
|
+
productionNodes ProductionNode[]
|
|
349
|
+
operations Operation[] @relation("OperationToOperationGroup")
|
|
350
|
+
|
|
351
|
+
@@map("operation_group")
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
model OperationRegister {
|
|
355
|
+
id Int @id @default(autoincrement())
|
|
356
|
+
machineId String
|
|
357
|
+
operatorId String
|
|
358
|
+
operationId String?
|
|
359
|
+
operationGroupId Int?
|
|
360
|
+
productionOrderId String
|
|
361
|
+
startTime DateTime @default(now()) @db.Timestamp(6)
|
|
362
|
+
endTime DateTime? @db.Timestamp(6)
|
|
363
|
+
elapsedTime BigInt?
|
|
364
|
+
productionNodeId String?
|
|
365
|
+
tenantId String?
|
|
366
|
+
quantity Int @default(1)
|
|
367
|
+
machine Machine @relation(fields: [machineId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_machine")
|
|
368
|
+
operator Operator @relation(fields: [operatorId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_operator")
|
|
369
|
+
operationGroup OperationGroup? @relation(fields: [operationGroupId], references: [id])
|
|
370
|
+
operation Operation? @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
371
|
+
productionNode ProductionNode? @relation(fields: [productionNodeId], references: [id])
|
|
372
|
+
productionOrder ProductionOrder @relation(fields: [productionOrderId], references: [id])
|
|
373
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
374
|
+
|
|
375
|
+
@@map("operation_register")
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
model OperationToOperation {
|
|
379
|
+
amount Int
|
|
380
|
+
inputOperationId String
|
|
381
|
+
outputOperationId String
|
|
382
|
+
tenantId String?
|
|
383
|
+
inputOperation Operation @relation("inputOperation", fields: [inputOperationId], references: [id], onDelete: Cascade)
|
|
384
|
+
outputOperation Operation @relation("outputOperation", fields: [outputOperationId], references: [id], onDelete: Cascade)
|
|
385
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
386
|
+
|
|
387
|
+
@@id([inputOperationId, outputOperationId])
|
|
388
|
+
@@map("operation_to_operation")
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
model Operator {
|
|
392
|
+
id String @id @default(cuid())
|
|
393
|
+
name String @unique
|
|
394
|
+
nickname String?
|
|
395
|
+
birthDate DateTime? @db.Date
|
|
396
|
+
phoneNumber String?
|
|
397
|
+
profileImgUrl String?
|
|
398
|
+
stringfiedProfileImgUrl String?
|
|
399
|
+
operatorRoleId String?
|
|
400
|
+
isDeleted Boolean @default(false)
|
|
401
|
+
tenantId String?
|
|
402
|
+
downtimeEvents DowntimeEvent[]
|
|
403
|
+
operationRegisters OperationRegister[]
|
|
404
|
+
operatorRole OperatorRole? @relation(fields: [operatorRoleId], references: [id])
|
|
405
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
406
|
+
ProductionNode ProductionNode?
|
|
407
|
+
habilityResources Resource[] @relation("OperatorToResource")
|
|
408
|
+
shifts Shift[] @relation("OperatorToShift")
|
|
409
|
+
|
|
410
|
+
@@map("operator")
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
model OperatorRole {
|
|
414
|
+
id String @id @default(cuid())
|
|
415
|
+
name String
|
|
416
|
+
isDeleted Boolean @default(false)
|
|
417
|
+
tenantId String?
|
|
418
|
+
operators Operator[]
|
|
419
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
420
|
+
|
|
421
|
+
@@map("operator_role")
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
model Panel {
|
|
425
|
+
id String @id @default(cuid())
|
|
426
|
+
title String
|
|
427
|
+
userId String @map("user_id")
|
|
428
|
+
tenantId String?
|
|
429
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
430
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
431
|
+
reports Report[] @relation("PanelToReport")
|
|
432
|
+
|
|
433
|
+
@@map("panel")
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
model PasswordResetToken {
|
|
437
|
+
id String @id @default(cuid())
|
|
438
|
+
email String
|
|
439
|
+
token String @unique
|
|
440
|
+
expires DateTime
|
|
441
|
+
|
|
442
|
+
@@unique([email, token])
|
|
443
|
+
@@map("password_reset_token")
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
model Permission {
|
|
447
|
+
id Int @id @default(autoincrement())
|
|
448
|
+
title Int?
|
|
449
|
+
description String?
|
|
450
|
+
user_permission UserPermission[]
|
|
451
|
+
|
|
452
|
+
@@map("permission")
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
model Product {
|
|
456
|
+
id String @id
|
|
457
|
+
name String
|
|
458
|
+
isLocal Boolean?
|
|
459
|
+
isDeleted Boolean @default(false)
|
|
460
|
+
tenantId String?
|
|
461
|
+
flows Flow[]
|
|
462
|
+
itemsHandlingRegisters ItemsHandlingRegister[]
|
|
463
|
+
node Node[]
|
|
464
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
465
|
+
composedBy ProductComponents[] @relation("componentOf")
|
|
466
|
+
componentOf ProductComponents[] @relation("composedBy")
|
|
467
|
+
operations ProductToOperation[]
|
|
468
|
+
productionOrders ProductionOrder[]
|
|
469
|
+
|
|
470
|
+
@@map("product")
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
model ProductComponents {
|
|
474
|
+
composedById String
|
|
475
|
+
componentOfId String
|
|
476
|
+
quantity Int
|
|
477
|
+
tenantId String?
|
|
478
|
+
componentOf Product @relation("componentOf", fields: [componentOfId], references: [id], onDelete: Cascade)
|
|
479
|
+
composedBy Product @relation("composedBy", fields: [composedById], references: [id], onDelete: Cascade)
|
|
480
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
481
|
+
|
|
482
|
+
@@id([componentOfId, composedById])
|
|
483
|
+
@@map("product_components")
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
model ProductionNode {
|
|
487
|
+
id String @id @default(cuid())
|
|
488
|
+
machineId String @unique
|
|
489
|
+
operatorId String? @unique
|
|
490
|
+
nodeId String @unique
|
|
491
|
+
operationId String?
|
|
492
|
+
operationGroupId Int?
|
|
493
|
+
productionOrderId String?
|
|
494
|
+
tenantId String?
|
|
495
|
+
operationRegister OperationRegister[]
|
|
496
|
+
machine Machine @relation(fields: [machineId], references: [id], onDelete: Cascade)
|
|
497
|
+
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
|
|
498
|
+
operationGroup OperationGroup? @relation(fields: [operationGroupId], references: [id])
|
|
499
|
+
operation Operation? @relation(fields: [operationId], references: [id])
|
|
500
|
+
operator Operator? @relation(fields: [operatorId], references: [id])
|
|
501
|
+
productionOrder ProductionOrder? @relation(fields: [productionOrderId], references: [id])
|
|
502
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
503
|
+
|
|
504
|
+
@@map("production_node")
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
model ProductionOrder {
|
|
508
|
+
id String @id @default(cuid())
|
|
509
|
+
productId String
|
|
510
|
+
flowId String?
|
|
511
|
+
productionOrderIndex Int? @unique
|
|
512
|
+
batchSize Float
|
|
513
|
+
hasStarted Boolean @default(false)
|
|
514
|
+
isRunning Boolean @default(false)
|
|
515
|
+
isFinished Boolean @default(false)
|
|
516
|
+
tenantId String?
|
|
517
|
+
ItemsHandlingRegister ItemsHandlingRegister[]
|
|
518
|
+
NodeOperationQueue NodeOperationQueue[]
|
|
519
|
+
operationRegisters OperationRegister[]
|
|
520
|
+
productionNode ProductionNode[]
|
|
521
|
+
flow Flow? @relation(fields: [flowId], references: [id])
|
|
522
|
+
Product Product @relation(fields: [productId], references: [id])
|
|
523
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
524
|
+
|
|
525
|
+
@@map("production_order")
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
model ProductToOperation {
|
|
529
|
+
amount Int
|
|
530
|
+
productId String
|
|
531
|
+
operationId String
|
|
532
|
+
tenantId String?
|
|
533
|
+
operation Operation @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
534
|
+
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
535
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
536
|
+
|
|
537
|
+
@@id([productId, operationId])
|
|
538
|
+
@@map("product_to_operation")
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
model Report {
|
|
542
|
+
id String @id @default(cuid())
|
|
543
|
+
title String
|
|
544
|
+
viewType String
|
|
545
|
+
data String
|
|
546
|
+
createdAt DateTime @default(now())
|
|
547
|
+
updatedAt DateTime? @updatedAt
|
|
548
|
+
tenantId String?
|
|
549
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
550
|
+
panels Panel[] @relation("PanelToReport")
|
|
551
|
+
|
|
552
|
+
@@map("report")
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
model Resource {
|
|
556
|
+
id String @id @default(cuid())
|
|
557
|
+
name String @unique
|
|
558
|
+
resourceType ResourceType
|
|
559
|
+
description String?
|
|
560
|
+
tenantId String?
|
|
561
|
+
Operation Operation[]
|
|
562
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
563
|
+
machines Machine[] @relation("MachineToResource")
|
|
564
|
+
operators Operator[] @relation("OperatorToResource")
|
|
565
|
+
|
|
566
|
+
@@map("resource")
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
model Sector {
|
|
570
|
+
id String @id @default(cuid())
|
|
571
|
+
name String @unique @db.VarChar(100)
|
|
572
|
+
description String? @db.VarChar(255)
|
|
573
|
+
isDeleted Boolean @default(false)
|
|
574
|
+
tenantId String?
|
|
575
|
+
stationFrom ItemsHandlingRegister[] @relation("sectorFrom")
|
|
576
|
+
stationTo ItemsHandlingRegister[] @relation("sectorTo")
|
|
577
|
+
machines Machine[]
|
|
578
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
579
|
+
|
|
580
|
+
@@map("sector")
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
model SewMachineRawData {
|
|
584
|
+
id String @id @default(cuid())
|
|
585
|
+
start_timestamp String
|
|
586
|
+
finish_timestamp String
|
|
587
|
+
stitches_count Int
|
|
588
|
+
line_cut Boolean @default(false)
|
|
589
|
+
machine_id String?
|
|
590
|
+
tenantId String?
|
|
591
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
592
|
+
|
|
593
|
+
@@map("sew_machine_raw_data")
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
model Shift {
|
|
597
|
+
id String @id @default(cuid())
|
|
598
|
+
name String @unique @db.VarChar(100)
|
|
599
|
+
start_time DateTime @db.Time(6)
|
|
600
|
+
end_time DateTime @db.Time(6)
|
|
601
|
+
tenantId String?
|
|
602
|
+
breaks Break[]
|
|
603
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
604
|
+
user_shift UserShift[]
|
|
605
|
+
operators Operator[] @relation("OperatorToShift")
|
|
606
|
+
|
|
607
|
+
@@map("shift")
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
model SystemPreferences {
|
|
611
|
+
id Int @id @default(autoincrement())
|
|
612
|
+
downtimeEventTime Int @default(300)
|
|
613
|
+
notificationTime Int @default(10)
|
|
614
|
+
lowPercentageColor Colors @default(red)
|
|
615
|
+
averagePercentageColor Colors @default(yellow)
|
|
616
|
+
highPercentageColor Colors @default(green)
|
|
617
|
+
averagePercentageValue Float @default(50)
|
|
618
|
+
highPercentageValue Float @default(80)
|
|
619
|
+
tenantId String?
|
|
620
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
621
|
+
|
|
622
|
+
@@map("system_preferences")
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
model TwoFactorConfirmation {
|
|
626
|
+
id String @id @default(cuid())
|
|
627
|
+
userId String @unique
|
|
628
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
629
|
+
|
|
630
|
+
@@map("two_factor_confirmation")
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
model TwoFactorToken {
|
|
634
|
+
id String @id @default(cuid())
|
|
635
|
+
email String
|
|
636
|
+
token String @unique
|
|
637
|
+
expires DateTime
|
|
638
|
+
|
|
639
|
+
@@unique([email, token])
|
|
640
|
+
@@map("two_factor_token")
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
model User {
|
|
644
|
+
id String @id @default(uuid())
|
|
645
|
+
name String
|
|
646
|
+
email String @unique
|
|
647
|
+
emailVerified DateTime?
|
|
648
|
+
image String?
|
|
649
|
+
password String
|
|
650
|
+
isTwoFactorEnabled Boolean @default(false)
|
|
651
|
+
role UserRole @default(USER)
|
|
652
|
+
tenantId String?
|
|
653
|
+
accounts Account[]
|
|
654
|
+
follows Follower[]
|
|
655
|
+
NotificationToUser NotificationToUser[]
|
|
656
|
+
Panel Panel[]
|
|
657
|
+
twoFactorConfirmation TwoFactorConfirmation?
|
|
658
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
659
|
+
userPermissions UserPermission[]
|
|
660
|
+
UserShift UserShift[]
|
|
661
|
+
|
|
662
|
+
@@map("user")
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
model UserPermission {
|
|
666
|
+
id Int @id @default(autoincrement())
|
|
667
|
+
userId String @map("user_id")
|
|
668
|
+
permission_id Int?
|
|
669
|
+
tenantId String?
|
|
670
|
+
permission Permission? @relation(fields: [permission_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_permission")
|
|
671
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
672
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
673
|
+
|
|
674
|
+
@@map("user_permission")
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
model UserShift {
|
|
678
|
+
id Int @id @default(autoincrement())
|
|
679
|
+
userId String @map("user_id")
|
|
680
|
+
shift_id String?
|
|
681
|
+
tenantId String?
|
|
682
|
+
shift Shift? @relation(fields: [shift_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_shift")
|
|
683
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
684
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
685
|
+
|
|
686
|
+
@@map("user_shift")
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
model VerificationToken {
|
|
690
|
+
id String @id @default(cuid())
|
|
691
|
+
token String @unique
|
|
692
|
+
expires DateTime
|
|
693
|
+
email String
|
|
694
|
+
|
|
695
|
+
@@unique([email, token])
|
|
696
|
+
@@map("verification_token")
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
model NodeOperationQueue {
|
|
700
|
+
id String @id @default(uuid())
|
|
701
|
+
nodeId String
|
|
702
|
+
operationId String
|
|
703
|
+
position Int
|
|
704
|
+
createdAt DateTime @default(now())
|
|
705
|
+
updatedAt DateTime @updatedAt
|
|
706
|
+
productionOrderId String
|
|
707
|
+
tenantId String?
|
|
708
|
+
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
|
|
709
|
+
operation Operation @relation(fields: [operationId], references: [id], onDelete: Cascade)
|
|
710
|
+
productionOrder ProductionOrder @relation(fields: [productionOrderId], references: [id], onDelete: Cascade)
|
|
711
|
+
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
712
|
+
|
|
713
|
+
@@map("node_operation_queue")
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
enum UserRole {
|
|
717
|
+
ADMIN
|
|
718
|
+
USER
|
|
719
|
+
VIEWER
|
|
720
|
+
BLOCKED
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
enum ResourceType {
|
|
724
|
+
HABILITY
|
|
725
|
+
OPERATION
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
enum NodeType {
|
|
729
|
+
Operation
|
|
730
|
+
Production
|
|
731
|
+
Product
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
enum Colors {
|
|
735
|
+
red
|
|
736
|
+
green
|
|
737
|
+
blue
|
|
738
|
+
yellow
|
|
739
|
+
orange
|
|
740
|
+
pink
|
|
741
|
+
violet
|
|
742
|
+
}
|