Skip to content

Commit 6cadd43

Browse files
committed
Add startup scripts for development environment setup
1 parent 7352bf5 commit 6cadd43

File tree

3 files changed

+362
-34
lines changed

3 files changed

+362
-34
lines changed

app/prisma/schema.prisma

Lines changed: 246 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@ datasource db {
88
}
99

1010
model Decider {
11-
id Int @id @default(autoincrement())
11+
id Int @id @default(autoincrement())
1212
first_name String
1313
last_name String
14-
email String @unique
14+
email String @unique
1515
password String
1616
phone String?
17+
created_at DateTime @default(now())
18+
updated_at DateTime @default(now())
1719
}
1820

1921
model SuperAdmin {
20-
id Int @id @default(autoincrement())
22+
id Int @id @default(autoincrement())
2123
first_name String
2224
last_name String
23-
email String @unique
25+
email String @unique
2426
password String
2527
phone String?
28+
created_at DateTime @default(now())
29+
updated_at DateTime @default(now())
2630
admins Admin[]
2731
}
2832

@@ -35,6 +39,8 @@ model Admin {
3539
phone String?
3640
add_by Int
3741
privilege Int
42+
created_at DateTime @default(now())
43+
updated_at DateTime @default(now())
3844
superAdmin SuperAdmin @relation(fields: [add_by], references: [id], onDelete: Cascade)
3945
}
4046

@@ -45,32 +51,40 @@ model Maintainer {
4551
email String @unique
4652
password String
4753
phone String?
54+
created_at DateTime @default(now())
55+
updated_at DateTime @default(now())
4856
DispoIssue DispoIssue[]
4957
Intervention Intervention[]
5058
}
5159

5260
model User {
53-
id Int @id @default(autoincrement())
54-
email String @unique
55-
first_name String
56-
last_name String
57-
password String
58-
phone String?
59-
created_at DateTime @default(now())
60-
Dispositive Dispositive[]
61-
Quotation Quotation[]
62-
Transaction Transaction[]
63-
helpers Helper[] @relation("UserHelpers")
61+
id Int @id @default(autoincrement())
62+
email String @unique
63+
first_name String
64+
last_name String
65+
password String
66+
phone String?
67+
created_at DateTime @default(now())
68+
MAC String
69+
updated_at DateTime @default(now())
70+
Dispositive Dispositive[]
71+
Environment Environment[]
72+
HelperRecommendation HelperRecommendation[]
73+
Quotation Quotation[]
74+
Transaction Transaction[]
75+
helpers Helper[] @relation("UserHelpers")
6476
}
6577

6678
model Helper {
67-
id Int @id @default(autoincrement())
79+
id Int @id @default(autoincrement())
6880
first_name String
6981
last_name String
70-
email String @unique
82+
email String @unique
7183
password String
7284
phone String?
73-
users User[] @relation("UserHelpers")
85+
created_at DateTime @default(now())
86+
updated_at DateTime @default(now())
87+
users User[] @relation("UserHelpers")
7488
}
7589

7690
model Commercial {
@@ -80,6 +94,8 @@ model Commercial {
8094
email String @unique
8195
password String
8296
phone String?
97+
created_at DateTime @default(now())
98+
updated_at DateTime @default(now())
8399
Transaction Transaction[]
84100
}
85101

@@ -93,6 +109,8 @@ model Dispositive {
93109
state String
94110
user_id Int?
95111
product_id Int
112+
created_at DateTime @default(now())
113+
updated_at DateTime @default(now())
96114
DispoIssue DispoIssue[]
97115
Product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
98116
User User? @relation(fields: [user_id], references: [id], onDelete: Cascade)
@@ -105,6 +123,8 @@ model Product {
105123
name String
106124
description String?
107125
price Float
126+
created_at DateTime @default(now())
127+
updated_at DateTime @default(now())
108128
Dispositive Dispositive[]
109129
ProductQuotation ProductQuotation[]
110130
}
@@ -113,25 +133,31 @@ model ProductQuotation {
113133
quotation_id Int
114134
product_id Int
115135
count Int
136+
created_at DateTime @default(now())
137+
updated_at DateTime
116138
Product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
117139
Quotation Quotation @relation(fields: [quotation_id], references: [id], onDelete: Cascade)
118140
119141
@@id([quotation_id, product_id])
120142
}
121143

122144
model ProductTransaction {
123-
id Int @id @default(autoincrement())
124145
transaction_id Int
125146
dispositive_id Int
126147
isConfirmed Boolean @default(false)
148+
created_at DateTime @default(now())
149+
updated_at DateTime
127150
Dispositive Dispositive @relation(fields: [dispositive_id], references: [id])
128-
Transaction Transaction @relation(fields: [transaction_id], references: [id])
151+
Transaction Transaction @relation(fields: [transaction_id], references: [id], onDelete: Cascade)
152+
153+
@@id([transaction_id, dispositive_id])
129154
}
130155

131156
model Quotation {
132157
id Int @id @default(autoincrement())
133158
user_id Int
134-
date DateTime
159+
created_at DateTime @default(now())
160+
updated_at DateTime
135161
ProductQuotation ProductQuotation[]
136162
User User @relation(fields: [user_id], references: [id], onDelete: Cascade)
137163
}
@@ -140,8 +166,8 @@ model Transaction {
140166
id Int @id @default(autoincrement())
141167
user_id Int
142168
commercial_id Int
143-
processed Boolean @default(false)
144-
date DateTime
169+
created_at DateTime @default(now())
170+
updated_at DateTime
145171
ProductTransaction ProductTransaction[]
146172
Commercial Commercial @relation(fields: [commercial_id], references: [id], onDelete: Cascade)
147173
User User @relation(fields: [user_id], references: [id], onDelete: Cascade)
@@ -151,24 +177,185 @@ model DispoIssue {
151177
id Int @id @default(autoincrement())
152178
dispositiveId Int
153179
description String
154-
date DateTime @default(now())
155-
status String
180+
status String @default("pending")
156181
maintainerId Int?
182+
created_at DateTime @default(now())
183+
updated_at DateTime @default(now())
157184
Dispositive Dispositive @relation(fields: [dispositiveId], references: [id])
158185
Maintainer Maintainer? @relation(fields: [maintainerId], references: [id])
159186
}
160187

161188
model Intervention {
162-
idMaintainer Int
189+
idMaintainer Int
190+
description String
191+
type String
192+
end_date DateTime
193+
start_date DateTime @default(now())
194+
id Int @id @default(autoincrement())
195+
status InterventionStatus @default(pending)
196+
idDispositive Int
197+
created_at DateTime @default(now())
198+
updated_at DateTime @default(now())
199+
Dispositive Dispositive @relation(fields: [idDispositive], references: [id])
200+
Maintainer Maintainer @relation(fields: [idMaintainer], references: [id])
201+
InterventionReport InterventionReport?
202+
}
203+
204+
model Assistance {
205+
id Int @id @default(autoincrement())
206+
first_name String
207+
last_name String
208+
email String @unique
209+
password String
210+
phone String?
211+
created_at DateTime @default(now())
212+
updated_at DateTime @default(now())
213+
}
214+
215+
model CircularLimits {
216+
id Int @id @default(autoincrement())
217+
centerPointId Int
218+
radius Float
219+
zoneId Int @unique
220+
Point Point @relation(fields: [centerPointId], references: [id])
221+
Zone Zone @relation(fields: [zoneId], references: [id])
222+
}
223+
224+
model ElementsLimits {
225+
id Int @id @default(autoincrement())
226+
limits_id Int @unique
227+
Zone Zone @relation(fields: [limits_id], references: [id])
228+
ElementsLimitsToEnvironmentElement ElementsLimitsToEnvironmentElement[]
229+
}
230+
231+
model ElementsLimitsToEnvironmentElement {
232+
id Int @id @default(autoincrement())
233+
elementsLimitsId Int
234+
environmentId Int
235+
objectId Int
236+
ElementsLimits ElementsLimits @relation(fields: [elementsLimitsId], references: [id])
237+
EnvironmentElement EnvironmentElement @relation(fields: [environmentId, objectId], references: [environmentId, objectId])
238+
239+
@@unique([elementsLimitsId, environmentId, objectId])
240+
}
241+
242+
model Environment {
243+
id Int @id @default(autoincrement())
244+
userId Int
245+
User User @relation(fields: [userId], references: [id])
246+
EnvironmentElement EnvironmentElement[]
247+
Zone Zone[]
248+
}
249+
250+
model EnvironmentElement {
251+
environmentId Int
252+
objectId Int
253+
ElementsLimitsToEnvironmentElement ElementsLimitsToEnvironmentElement[]
254+
Environment Environment @relation(fields: [environmentId], references: [id])
255+
Object Object @relation(fields: [objectId], references: [id])
256+
257+
@@id([environmentId, objectId])
258+
}
259+
260+
model HelperRecommendation {
261+
id Int @id @default(autoincrement())
262+
first_name String
263+
last_name String
264+
email String
265+
phone String?
266+
status String @default("pending")
267+
user_id Int
268+
notes String?
269+
created_at DateTime @default(now())
270+
updated_at DateTime @default(now())
271+
User User @relation(fields: [user_id], references: [id])
272+
}
273+
274+
model InterventionReport {
275+
id Int @id @default(autoincrement())
276+
interventionId Int @unique
277+
title String
278+
description String
279+
created_at DateTime @default(now())
280+
updated_at DateTime @default(now())
281+
Intervention Intervention @relation(fields: [interventionId], references: [id], onDelete: Cascade)
282+
}
283+
284+
model Notification {
285+
id Int @id @default(autoincrement())
286+
user_id Int
287+
type String?
288+
title String
289+
message String
290+
metadata Json?
291+
is_read Boolean @default(false)
292+
created_at DateTime @default(now())
293+
sent_at DateTime?
294+
read_at DateTime?
295+
user_type UserType @default(USER)
296+
}
297+
298+
model Object {
299+
id Int @id @default(autoincrement())
300+
EnvironmentElement EnvironmentElement[]
301+
}
302+
303+
model POI {
304+
id Int @id @default(autoincrement())
305+
coordinates String
306+
poiCategoryId Int
307+
name String
163308
description String
164-
type String
165-
end_date DateTime
166-
start_date DateTime @default(now())
167-
id Int @id @default(autoincrement())
168-
status InterventionStatus @default(pending)
169-
idDispositive Int
170-
Dispositive Dispositive @relation(fields: [idDispositive], references: [id])
171-
Maintainer Maintainer @relation(fields: [idMaintainer], references: [id])
309+
POICategory POICategory @relation(fields: [poiCategoryId], references: [id])
310+
Zone Zone[]
311+
}
312+
313+
model POICategory {
314+
id Int @id @default(autoincrement())
315+
name String
316+
POI POI[]
317+
}
318+
319+
model Point {
320+
id Int @id @default(autoincrement())
321+
x Float
322+
y Float
323+
CircularLimits CircularLimits[]
324+
PolygonLimits PolygonLimits[]
325+
PointsLimits PointsLimits[]
326+
}
327+
328+
model PointsLimits {
329+
id Int @id @default(autoincrement())
330+
limits_id Int @unique
331+
Zone Zone @relation(fields: [limits_id], references: [id])
332+
Point Point[]
333+
}
334+
335+
model PolygonLimits {
336+
id Int @id @default(autoincrement())
337+
centerPointId Int
338+
radius Float
339+
facesNb Int
340+
rotation Float
341+
limits_id Int @unique
342+
Point Point @relation(fields: [centerPointId], references: [id])
343+
Zone Zone @relation(fields: [limits_id], references: [id])
344+
}
345+
346+
model Zone {
347+
id Int @id @default(autoincrement())
348+
environmentId Int
349+
zoneType ZoneType
350+
limitsType LimitsType
351+
color String
352+
icon String
353+
CircularLimits CircularLimits?
354+
ElementsLimits ElementsLimits?
355+
PointsLimits PointsLimits?
356+
PolygonLimits PolygonLimits?
357+
Environment Environment @relation(fields: [environmentId], references: [id])
358+
POI POI[]
172359
}
173360

174361
enum InterventionStatus {
@@ -177,3 +364,28 @@ enum InterventionStatus {
177364
pending
178365
rescheduled
179366
}
367+
368+
enum LimitsType {
369+
CIRCULAR
370+
POLYGON
371+
POINTS
372+
ELEMENTS
373+
}
374+
375+
enum UserType {
376+
USER
377+
COMMERCIAL
378+
ADMIN
379+
SUPERADMIN
380+
MAINTAINER
381+
DECIDER
382+
HELPER
383+
}
384+
385+
enum ZoneType {
386+
CIRCULATION
387+
WORK
388+
SERVICE
389+
FORBIDDEN
390+
DANGER
391+
}

0 commit comments

Comments
 (0)