-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.prisma
More file actions
152 lines (129 loc) · 3.83 KB
/
schema.prisma
File metadata and controls
152 lines (129 loc) · 3.83 KB
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
//schema.prisma
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-3.0.x"]
previewFeatures = ["typedSql","relationJoins"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
// https://github.com/prisma/prisma/discussions/25106#discussioncomment-10500102
directUrl = env("DIRECT_URL")
}
enum Day {
mon
tue
wed
thu
fri
sat
sun
other
}
model User {
// identifiers
id Int @id @default(autoincrement())
guid String @unique
// profile
name String
gender String
grade String
faculty String
department String
intro String
pictureUrl String @default("/avatar.svg")
// bindings to other parts of this app
enrollments Enrollment[]
sendingUsers Relationship[] @relation("sending") // 自分がマッチリクエストを送ったユーザー
receivingUsers Relationship[] @relation("receiving") // 自分にマッチリクエストを送ったユーザー
interests Interest[]
}
model Avatar {
guid String @id
data Bytes
}
model Picture {
hash String @id
data Bytes
key String // password
}
model InterestSubject {
id Int @id @default(autoincrement())
name String
group String // such as Computer Science | name = ML
Interest Interest[] // ignore this
@@unique([name, group])
}
// User->Interest->InterestSubject
model Interest {
userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade )
subjectId Int
subject InterestSubject @relation(fields: [subjectId], references: [id], onDelete: Cascade)
@@unique([userId, subjectId])
}
// enum Gender {
// MALE
// FEMALE
// OTHER
// SECRET
// }
model Course {
id String @id
name String
teacher String
enrollments Enrollment[]
slots Slot[]
}
// コマ。1つの講義に対して複数存在しうる。
model Slot {
id Int @id @default(autoincrement())
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
courseId String
period Int // 1-6. 0 の場合はなし (集中など)
day Day // 曜日。other の場合は集中など
@@unique([courseId, period, day])
}
model Enrollment {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
courseId String
@@unique([userId, courseId])
}
model Relationship {
id Int @id @default(autoincrement())
status MatchingStatus
sendingUser User @relation("sending", fields: [sendingUserId], references: [id], onDelete: Cascade)
sendingUserId Int
receivingUser User @relation("receiving", fields: [receivingUserId], references: [id], onDelete: Cascade)
receivingUserId Int
messages Message[]
@@unique([sendingUserId, receivingUserId])
}
enum MatchingStatus {
PENDING
MATCHED
REJECTED
}
model SharedRoom {
id Int @id @default(autoincrement())
thumbnail String // URL to thumbnail picture
name String
members Int[]
messages Message[]
}
model Message {
id Int @id @default(autoincrement())
creator Int // refers to UserId
createdAt DateTime @default(now()) // @readonly
edited Boolean @default(false)
content String
isPicture Boolean // iff the message is a picture. if true, then content is a url of picture.
read Boolean @default(false)
relation Relationship? @relation(fields: [relationId], references: [id], onDelete: Cascade)
relationId Int?
sharedRoom SharedRoom? @relation(fields: [sharedRoomId], references: [id], onDelete: Cascade)
sharedRoomId Int?
}