-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.prisma
270 lines (189 loc) · 7 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
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}
datasource db {
provider = "mysql"
url = env("DB_URL")
shadowDatabaseUrl = env("DB_SHADOW_URL")
}
enum Provider {
KAKAO
GOOGLE
APPLE
}
enum DestinationType {
STATIC
DYNAMIC
}
enum LocationShareType {
DISTANCE
TIME
}
model User {
id Int @id @default(autoincrement()) @db.UnsignedInt
/// 사용자 이름
username String? @db.VarChar(80)
/// 프로필 이미지 URL
profileUrl String? @map("profile_url") @db.Text
/// OAuth 공급자
provider Provider
/// OAuth 공급자에서 제공하는 사용자 ID
providerId String? @map("provider_id") @db.VarChar(100)
/// 탈퇴 시간
deletedAt DateTime? @map("deleted_at") @db.Timestamp(0)
/// 탈퇴 사유
leaveReason String? @map("leave_reason") @db.VarChar(255)
/// 마지막 로그인 시간
lastSignedAt DateTime @default(now()) @map("last_signed_at") @db.Timestamp(0)
/// 생성일
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
/// 수정일
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(0)
/// 내가 약속장인 약속 목록
myPromises Promise[] @relation(name: "Promise.host")
/// 내가 참여한 약속 목록
promises PromiseUser[] @relation(name: "PromiseUser.attendee")
/// 로그 뮤테이션 목록
mutationLogs MutationLog[] @relation(name: "MutationLog.user")
@@unique(name: "identifier", fields: [provider, providerId], map: "ix_provider")
@@map("pm_users")
}
model Promise {
id Int @id @default(autoincrement()) @db.UnsignedInt
/// 약속장 ID
hostId Int @map("host_id") @db.UnsignedInt
/// 약속장
host User @relation(name: "Promise.host", fields: [hostId], references: [id], onDelete: Cascade)
/// 약속 제목
title String @db.VarChar(50)
/// 목적지 유형
destinationType DestinationType @map("destination_type")
/// 목적지 ID
destinationId Int? @map("destination_id") @db.UnsignedInt
/// 목적지
destination Location? @relation(name: "Promise.destination", fields: [destinationId], references: [id], onDelete: SetNull)
/// 최신 목적지 여부
isLatestDestination Boolean @default(false) @map("is_latest_destination")
/// 위치 공유 시작 유형
locationShareStartType LocationShareType @map("location_share_start_type")
/// 위치 공유 시작 값
locationShareStartValue Int @map("location_share_start_value") @db.UnsignedInt
/// 위치 공유 종료 유형
locationShareEndType LocationShareType @map("location_share_end_type")
/// 위치 공유 종료 값
locationShareEndValue Int @map("location_share_end_value") @db.UnsignedInt
/// 약속 시간
promisedAt DateTime @map("promised_at") @db.Timestamp(0)
/// 약속 완료 시간
completedAt DateTime? @map("completed_at") @db.Timestamp(0)
/// 생성일
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
/// 수정일
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(0)
/// 참여자 목록
attendees PromiseUser[] @relation(name: "PromiseUser.promise")
/// 테마 목록
themes PromiseTheme[] @relation(name: "PromiseTheme.promise")
@@unique(fields: [destinationId], map: "ix_destination_id")
@@index(fields: [hostId], map: "ix_host_id")
@@map("pm_promises")
}
model PromiseUser {
/// 약속 ID
promiseId Int @map("promise_id") @db.UnsignedInt
/// 약속
promise Promise @relation(name: "PromiseUser.promise", fields: [promiseId], references: [id], onDelete: Cascade)
/// 약속 참여자 ID
attendeeId Int @map("attendee_id") @db.UnsignedInt
/// 약속 참여자
attendee User @relation(name: "PromiseUser.attendee", fields: [attendeeId], references: [id], onDelete: Cascade)
/// 약속 참여자 출발지 ID
startLocationId Int? @map("start_location_id") @db.UnsignedInt
/// 약속 참여자 출발지
startLocation Location? @relation(name: "PromiseUser.startLocation", fields: [startLocationId], references: [id], onDelete: SetNull)
/// 중간 지점 계산 인수 여부
isMidpointCalculated Boolean @default(false) @map("is_midpoint_calculated")
/// 참여 시간
attendedAt DateTime @default(now()) @map("attended_at") @db.Timestamp(0)
/// 탈퇴 시간
leavedAt DateTime? @map("leaved_at") @db.Timestamp(0)
@@id(name: "identifier", fields: [promiseId, attendeeId])
@@unique(fields: [startLocationId], map: "ix_start_location_id")
@@index(fields: [attendeeId], map: "ix_attendee_id")
@@index(fields: [promiseId], map: "ix_promise_id")
@@map("pm_promise_users")
}
model Theme {
id Int @id @default(autoincrement()) @db.UnsignedInt
/// 테마 이름
name String @db.VarChar(10)
/// 약속 목록
promises PromiseTheme[] @relation(name: "PromiseTheme.theme")
@@map("pm_themes")
}
model PromiseTheme {
/// 약속 ID
promiseId Int @map("promise_id") @db.UnsignedInt
/// 약속
promise Promise @relation(name: "PromiseTheme.promise", fields: [promiseId], references: [id], onDelete: Cascade)
/// 테마 ID
themeId Int @map("theme_id") @db.UnsignedInt
/// 테마
theme Theme @relation(name: "PromiseTheme.theme", fields: [themeId], references: [id], onDelete: Cascade)
@@id(name: "identifier", fields: [promiseId, themeId])
@@index(fields: [themeId], map: "ix_theme_id")
@@index(fields: [promiseId], map: "ix_promise_id")
@@map("pm_promise_themes")
}
model Location {
id Int @id @default(autoincrement()) @db.UnsignedInt
/// 이름
name String? @db.VarChar(20)
/// 시/도
city String @db.VarChar(10)
/// 구/군
district String @db.VarChar(5)
/// 도로명/지번
address1 String @db.VarChar(20)
/// 상세 주소
address2 String? @db.VarChar(50)
/// 위도 (-90 ~ 90)
latitude Decimal @db.Decimal(10, 8)
/// 경도 (-180 ~ 180)
longitude Decimal @db.Decimal(11, 8)
/// 생성일
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
/// 수정일
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(0)
/// 약속 목록
promises Promise[] @relation(name: "Promise.destination")
/// 약속 참여 목록
promiseUsers PromiseUser[] @relation(name: "PromiseUser.startLocation")
@@map("pm_locations")
}
model MutationLog {
id Int @id @default(autoincrement()) @db.UnsignedInt
/// 사용자 ID
userId Int @map("user_id") @db.UnsignedInt
/// 사용자
user User @relation(name: "MutationLog.user", fields: [userId], references: [id], onDelete: Cascade)
/// HTTP 메서드
method String @db.VarChar(8)
/// 요청 URL
url String @db.VarChar(255)
/// 요청 헤더
headers Json?
/// 응답 상태 코드
statusCode Int @map("status_code") @db.UnsignedSmallInt
/// 요청 본문
requestBody Json? @map("request_body")
/// 응답 본문
responseBody Json? @map("response_body")
/// 처리 시간
duration Int @db.UnsignedInt
/// 생성 시간
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
@@index(fields: [userId], map: "ix_user_id")
@@map("pm_mutation_logs")
}