-
Notifications
You must be signed in to change notification settings - Fork 12
/
schema.prisma
89 lines (77 loc) · 1.82 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
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String
surname String
password String
created_at DateTime @default(now())
updated_at DateTime @updatedAt @default(now())
}
model Greenhouse {
id String @id @default(uuid())
name String
description String?
plants Plant[]
data Data[]
isOkay Boolean @default(true)
created_at DateTime @default(now())
updated_at DateTime @updatedAt @default(now())
}
model Sensor {
name String @id
type SensorType
positionType PositionType
data Data[]
positionRelation Position @relation(fields: [positionType], references: [type])
}
model Data {
id Int @id @default(autoincrement())
sensor String
value Float
greenhouseId String
created_at DateTime @default(now())
updated_at DateTime @updatedAt @default(now())
// Relation fields
GreenhouseRelation Greenhouse @relation(fields: [greenhouseId], references: [id])
SensorRelation Sensor @relation(fields: [sensor], references: [name])
}
model Plant {
id Int @id @default(autoincrement())
name String
description String?
greenhouseId String?
created_at DateTime @default(now())
updated_at DateTime @updatedAt @default(now())
isDeleted Boolean @default(false)
positionType PositionType
// Relation field
greenhouse Greenhouse? @relation(fields: [greenhouseId], references: [id])
positionRelation Position @relation(fields: [positionType], references: [type])
}
model Position {
type PositionType @id
name String
sensors Sensor[]
plants Plant[]
}
enum PositionType {
TOP_LEFT
TOP_RIGHT
MIDDLE_LEFT
MIDDLE_RIGHT
BOTTOM_LEFT
BOTTOM_RIGHT
GENERAL
}
enum SensorType {
HUMIDITY
TEMPERATURE
SOIL_MOISTURE
}