-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
344 lines (307 loc) · 14.4 KB
/
schema.prisma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
// This file is automatically generated by Keystone, do not modify it manually.
// Modify your Keystone config when you want to change this.
datasource sqlite {
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
provider = "sqlite"
}
generator client {
provider = "prisma-client-js"
}
model Application {
id String @id @default(cuid())
workOrder WorkOrder? @relation("Application_workOrder", fields: [workOrderId], references: [id])
workOrderId String? @map("workOrder")
images File[] @relation("File_application")
startedAt DateTime?
finishedAt DateTime?
name String @default("")
description String @default("")
value Float
amount Float
wastage Float? @default(0)
location ApplicationLocation? @relation("Application_location", fields: [locationId], references: [id])
locationId String? @map("location")
product Product? @relation("Application_product", fields: [productId], references: [id])
productId String? @map("product")
applicant User? @relation("Application_applicant", fields: [applicantId], references: [id])
applicantId String? @map("applicant")
creator User? @relation("Application_creator", fields: [creatorId], references: [id])
creatorId String? @map("creator")
type ApplicationType? @relation("Application_type", fields: [typeId], references: [id])
typeId String? @map("type")
stockMovements StockMovement[] @relation("StockMovement_application")
@@index([workOrderId])
@@index([locationId])
@@index([productId])
@@index([applicantId])
@@index([creatorId])
@@index([typeId])
}
model ApplicationLocation {
id String @id @default(cuid())
name String @default("")
applicationTypes ApplicationType[] @relation("ApplicationLocation_applicationTypes")
applications Application[] @relation("Application_location")
}
model ApplicationType {
id String @id @default(cuid())
name String @default("")
applications Application[] @relation("Application_type")
products Product[] @relation("Product_applicationType")
locations ApplicationLocation[] @relation("ApplicationLocation_applicationTypes")
}
model Car {
id String @id @default(cuid())
vin String @default("")
carModel CarModel? @relation("Car_carModel", fields: [carModelId], references: [id])
carModelId String? @map("carModel")
licensePlate String @default("")
workOrders WorkOrder[] @relation("WorkOrder_car")
@@index([carModelId])
}
model CarBrand {
id String @id @default(cuid())
name String @default("")
carModels CarModel[] @relation("CarModel_carBrand")
@@index([name])
}
model CarModel {
id String @id @default(cuid())
name String @default("")
cars Car[] @relation("Car_carModel")
carBrand CarBrand? @relation("CarModel_carBrand", fields: [carBrandId], references: [id])
carBrandId String? @map("carBrand")
@@index([name])
@@index([carBrandId])
}
model Document {
id String @id @default(cuid())
createdAt DateTime? @default(now())
documentType String @default("satış")
creator User? @relation("Document_creator", fields: [creatorId], references: [id])
creatorId String? @map("creator")
reductionType String? @default("inverse")
customer User? @relation("Document_customer", fields: [customerId], references: [id])
customerId String? @map("customer")
reduction Float? @default(0)
isDeleted Boolean @default(false)
number String @default("")
invoiced Boolean @default(false)
products DocumentProduct[] @relation("DocumentProduct_document")
paymentPlan PaymentPlan? @relation("Document_paymentPlan", fields: [paymentPlanId], references: [id])
paymentPlanId String? @unique @map("paymentPlan")
supplier Supplier? @relation("Document_supplier", fields: [supplierId], references: [id])
supplierId String? @map("supplier")
@@index([creatorId])
@@index([customerId])
@@index([supplierId])
}
model DocumentProduct {
id String @id @default(cuid())
amount Float
stockMovements StockMovement[] @relation("StockMovement_documentProduct")
product Product? @relation("DocumentProduct_product", fields: [productId], references: [id])
productId String? @map("product")
price Float
document Document? @relation("DocumentProduct_document", fields: [documentId], references: [id])
documentId String? @map("document")
@@index([productId])
@@index([documentId])
}
model File {
id String @id @default(cuid())
name String @default("")
url String @default("")
application Application? @relation("File_application", fields: [applicationId], references: [id])
applicationId String? @map("application")
workOrder WorkOrder? @relation("File_workOrder", fields: [workOrderId], references: [id])
workOrderId String? @map("workOrder")
product Product? @relation("File_product", fields: [productId], references: [id])
productId String? @map("product")
@@index([applicationId])
@@index([workOrderId])
@@index([productId])
}
model Note {
id String @id @default(cuid())
note String @default("")
workOrder WorkOrder? @relation("Note_workOrder", fields: [workOrderId], references: [id])
workOrderId String? @map("workOrder")
creator User? @relation("Note_creator", fields: [creatorId], references: [id])
creatorId String? @map("creator")
@@index([workOrderId])
@@index([creatorId])
}
model Notification {
id String @id @default(cuid())
date DateTime? @default(now())
message String @default("")
paymentPlan PaymentPlan? @relation("Notification_paymentPlan", fields: [paymentPlanId], references: [id])
paymentPlanId String? @map("paymentPlan")
workOrder WorkOrder? @relation("Notification_workOrder", fields: [workOrderId], references: [id])
workOrderId String? @map("workOrder")
link String @default("")
handled Boolean @default(false)
notifyRoles String @default("[]")
@@index([paymentPlanId])
@@index([workOrderId])
}
model Payment {
id String @id @default(cuid())
creationDate DateTime?
amount Float
paymentPlan PaymentPlan? @relation("Payment_paymentPlan", fields: [paymentPlanId], references: [id])
paymentPlanId String? @map("paymentPlan")
reference String @default("")
totalToDate Float?
type String @default("nakit")
out Boolean @default(false)
date DateTime? @default(now())
@@index([paymentPlanId])
}
model PaymentPlan {
id String @id @default(cuid())
name String @default("")
workOrder WorkOrder? @relation("PaymentPlan_workOrder", fields: [workOrderId], references: [id])
workOrderId String? @unique @map("workOrder")
payments Payment[] @relation("Payment_paymentPlan")
document Document? @relation("Document_paymentPlan")
periods Float @default(1)
periodDuration Float @default(1)
periodPayment Float @default(1)
periodDurationScale String @default("ay")
notifications Notification[] @relation("Notification_paymentPlan")
}
model Product {
id String @id @default(cuid())
name String @default("")
description String @default("")
price Float
suppliers Supplier[] @relation("Product_suppliers")
status String @default("aktif")
images File[] @relation("File_product")
code String @default("")
ean String @default("")
productBrand ProductBrand? @relation("Product_productBrand", fields: [productBrandId], references: [id])
productBrandId String? @map("productBrand")
pricedBy String @default("amount")
applications Application[] @relation("Application_product")
applicationType ApplicationType? @relation("Product_applicationType", fields: [applicationTypeId], references: [id])
applicationTypeId String? @map("applicationType")
stockMovements StockMovement[] @relation("StockMovement_product")
documentProducts DocumentProduct[] @relation("DocumentProduct_product")
warrantyType String @default("yok")
warrantyTimeScale String @default("yıl")
warrantyTime Float?
color String @default("")
width Float?
length Float?
height Float?
depth Float?
weight Float?
thickness Float?
extraFields String? @default("{\"colorWarranty\":false,\"customPricing\":{\"sideWindow\":\"\",\"windshield\":\"\",\"sunroof\":\"\",\"glassTop\":\"\",\"hood\":\"\",\"fender\":\"\",\"bumper\":\"\"}}")
@@index([productBrandId])
@@index([applicationTypeId])
}
model ProductBrand {
id String @id @default(cuid())
name String @default("")
products Product[] @relation("Product_productBrand")
}
model SoftwareVersion {
id Int @id
version Int
iosLink String @default("")
androidLink String @default("")
webLink String @default("")
windowsLink String @default("")
macLink String @default("")
date DateTime? @default(now())
}
model StockMovement {
id String @id @default(cuid())
product Product? @relation("StockMovement_product", fields: [productId], references: [id])
productId String? @map("product")
storage Storage? @relation("StockMovement_storage", fields: [storageId], references: [id])
storageId String? @map("storage")
amount Float
movementType String @default("giriş")
documentProduct DocumentProduct? @relation("StockMovement_documentProduct", fields: [documentProductId], references: [id])
documentProductId String? @map("documentProduct")
note String @default("")
customer User? @relation("StockMovement_customer", fields: [customerId], references: [id])
customerId String? @map("customer")
date DateTime? @default(now())
application Application? @relation("StockMovement_application", fields: [applicationId], references: [id])
applicationId String? @map("application")
createdAt DateTime? @default(now())
@@index([productId])
@@index([storageId])
@@index([documentProductId])
@@index([customerId])
@@index([applicationId])
}
model Storage {
id String @id @default(cuid())
name String @default("")
stockMovements StockMovement[] @relation("StockMovement_storage")
}
model Supplier {
id String @id @default(cuid())
name String @default("")
products Product[] @relation("Product_suppliers")
documents Document[] @relation("Document_supplier")
}
model User {
id String @id @default(cuid())
username String @unique @default("")
email String @unique @default("")
isBlocked Boolean @default(false)
phone String @default("")
firstname String @default("")
lastname String @default("")
role String @default("customer")
code String @default("")
permissions String @default("[]")
ssid String @default("")
password String
qcWorkOrders WorkOrder[] @relation("WorkOrder_qcUser")
workOrders WorkOrder[] @relation("WorkOrder_creator")
clientOrders WorkOrder[] @relation("WorkOrder_customer")
applicationsToApply Application[] @relation("Application_applicant")
applications Application[] @relation("Application_creator")
notes Note[] @relation("Note_creator")
documents Document[] @relation("Document_creator")
customerDocuments Document[] @relation("Document_customer")
customerMovements StockMovement[] @relation("StockMovement_customer")
@@index([role])
}
model WorkOrder {
id String @id @default(cuid())
creator User? @relation("WorkOrder_creator", fields: [creatorId], references: [id])
creatorId String? @map("creator")
createdAt DateTime? @default(now())
images File[] @relation("File_workOrder")
notes Note[] @relation("Note_workOrder")
status String? @default("pasif")
reductionType String? @default("inverse")
reduction Float?
paymentPlan PaymentPlan? @relation("PaymentPlan_workOrder")
qcDone Boolean @default(false)
qcUser User? @relation("WorkOrder_qcUser", fields: [qcUserId], references: [id])
qcUserId String? @map("qcUser")
checkDate DateTime?
checkDone Boolean @default(false)
notifications Notification[] @relation("Notification_workOrder")
car Car? @relation("WorkOrder_car", fields: [carId], references: [id])
carId String? @map("car")
customer User? @relation("WorkOrder_customer", fields: [customerId], references: [id])
customerId String? @map("customer")
applications Application[] @relation("Application_workOrder")
@@index([creatorId])
@@index([qcUserId])
@@index([carId])
@@index([customerId])
}