-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
118 lines (95 loc) · 3.06 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
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
userID Int @id @default(autoincrement())
firstName String
lastName String
// NOTE: Foreign key "links"
credential Credentials[]
plantation Plantation[]
notification Notification[]
}
model Credentials {
email String @id
password String
githubID String?
googleID String?
verified Boolean @default(false)
userID Int @unique
updatedAt Int
userAction UserAction[]
// NOTE: Foreign key (1:N relation with `User` table)
user User @relation(fields: [userID], references: [userID], onDelete: Cascade)
}
model UserAction {
// Model used for email verification and password reset
messageID Int @id @default(autoincrement())
email String
actionType String
credential Credentials @relation(fields: [email], references: [email], onDelete: Cascade, onUpdate: Cascade)
}
model Notification{
notificationID Int @id @default(autoincrement())
message String
notificationType String
notificationIcon String @default("warning_green.svg")
userID Int
user User @relation(fields: [userID], references: [userID], onDelete: Cascade)
}
model Location{
locationID Int @id @default(autoincrement())
locationName String?
locationCAP String? @db.Char(5)
locationLat Float
locationLong Float
plantation Plantation[]
}
model Plantation {
plantationID Int @id @default(autoincrement())
plantationName String
imageURL String @db.VarChar(500) @default("plantation.webp")
userID Int
locationID Int?
location Location? @relation(fields: [locationID], references: [locationID], onDelete: SetNull)
user User @relation(fields: [userID], references: [userID], onDelete: Cascade)
plantation_plant Plantation_Plant[]
}
model Plant {
plantID Int @id @default(autoincrement())
plantName String
plantFamily String?
plantDescription String?
scientificName String
imageURL String @db.VarChar(500) @default("plant.webp")
plantation_plant Plantation_Plant[]
}
model PlannedTreatment {
treatmentID Int @id @default(autoincrement())
treatmentType String
notes String @db.VarChar(300)
treatmentDate DateTime
treatmentRecurrence Int @default(0)
plantationPlantID Int
plantationPlant Plantation_Plant @relation(fields: [plantationPlantID], references: [plantationPlantID], onDelete: Cascade)
}
model Plantation_Plant {
plantationPlantID Int @id @default(autoincrement())
plantationID Int
plantID Int
plannedTreatment PlannedTreatment[]
plantation Plantation @relation(fields: [plantationID], references: [plantationID], onDelete: Cascade)
plant Plant @relation(fields: [plantID], references: [plantID], onDelete: Cascade)
}
model JWTBlacklist {
tokenID Int @id @default(autoincrement())
token String @db.VarChar(500) @unique
}