forked from openshiporg/openship
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
342 lines (310 loc) · 13.4 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
// This file is automatically generated by Keystone, do not modify it manually.
// Modify your Keystone config when you want to change this.
datasource postgresql {
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
provider = "postgresql"
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(cuid())
name String @default("")
email String @unique @default("")
password String
shops Shop[] @relation("Shop_user")
shopPlatforms ShopPlatform[] @relation("ShopPlatform_user")
channels Channel[] @relation("Channel_user")
channelPlatforms ChannelPlatform[] @relation("ChannelPlatform_user")
orders Order[] @relation("Order_user")
lineItems LineItem[] @relation("LineItem_user")
cartItems CartItem[] @relation("CartItem_user")
shopItems ShopItem[] @relation("ShopItem_user")
channelItems ChannelItem[] @relation("ChannelItem_user")
apiKeys apiKey[] @relation("apiKey_user")
matches Match[] @relation("Match_user")
links Link[] @relation("Link_user")
trackingDetails TrackingDetail[] @relation("TrackingDetail_user")
role Role? @relation("User_role", fields: [roleId], references: [id])
roleId String? @map("role")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
passwordResetToken String?
passwordResetIssuedAt DateTime?
passwordResetRedeemedAt DateTime?
@@index([roleId])
}
model apiKey {
id String @id @default(cuid())
user User? @relation("apiKey_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([userId])
}
model Role {
id String @id @default(cuid())
name String @default("")
canSeeOtherUsers Boolean @default(false)
canManageUsers Boolean @default(false)
canManageRoles Boolean @default(false)
canSeeOtherOrders Boolean @default(false)
canManageOrders Boolean @default(false)
canSeeOtherShops Boolean @default(false)
canManageShops Boolean @default(false)
canSeeOtherChannels Boolean @default(false)
canManageChannels Boolean @default(false)
canSeeOtherMatches Boolean @default(false)
canManageMatches Boolean @default(false)
canSeeOtherLinks Boolean @default(false)
canManageLinks Boolean @default(false)
assignedTo User[] @relation("User_role")
}
model Order {
id String @id @default(cuid())
orderId String @default("")
orderName String @default("")
email String @default("")
firstName String @default("")
lastName String @default("")
streetAddress1 String @default("")
streetAddress2 String @default("")
city String @default("")
state String @default("")
zip String @default("")
currency String @default("")
totalPrice String @default("")
subTotalPrice String @default("")
totalDiscount String @default("")
totalTax String @default("")
phoneNumber String @default("")
note String @default("")
shippingMethod Json?
country String @default("")
orderError String @default("")
status String @default("")
locationId Float?
user User? @relation("Order_user", fields: [userId], references: [id])
userId String? @map("user")
shop Shop? @relation("Order_shop", fields: [shopId], references: [id])
shopId String? @map("shop")
lineItems LineItem[] @relation("LineItem_order")
cartItems CartItem[] @relation("CartItem_order")
linkOrder Boolean @default(false)
matchOrder Boolean @default(false)
processOrder Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([userId])
@@index([shopId])
}
model TrackingDetail {
id String @id @default(cuid())
trackingCompany String @default("")
trackingNumber String @default("")
purchaseId String @default("")
cartItems CartItem[] @relation("CartItem_trackingDetails")
user User? @relation("TrackingDetail_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([userId])
}
model LineItem {
id String @id @default(cuid())
name String @default("")
image String @default("")
price String @default("")
quantity Int?
productId String @default("")
variantId String @default("")
sku String @default("")
lineItemId String @default("")
order Order? @relation("LineItem_order", fields: [orderId], references: [id])
orderId String? @map("order")
user User? @relation("LineItem_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([orderId])
@@index([userId])
}
model CartItem {
id String @id @default(cuid())
name String @default("")
image String @default("")
price String @default("")
quantity Int?
productId String @default("")
variantId String @default("")
lineItemId String @default("")
sku String @default("")
url String @default("")
error String @default("")
purchaseId String @default("")
status String @default("")
order Order? @relation("CartItem_order", fields: [orderId], references: [id])
orderId String? @map("order")
trackingDetails TrackingDetail[] @relation("CartItem_trackingDetails")
user User? @relation("CartItem_user", fields: [userId], references: [id])
userId String? @map("user")
channel Channel? @relation("CartItem_channel", fields: [channelId], references: [id])
channelId String? @map("channel")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([orderId])
@@index([userId])
@@index([channelId])
}
model Channel {
id String @id @default(cuid())
name String @default("")
domain String @default("")
accessToken String @default("")
links Link[] @relation("Link_channel")
platform ChannelPlatform? @relation("Channel_platform", fields: [platformId], references: [id])
platformId String? @map("platform")
channelItems ChannelItem[] @relation("ChannelItem_channel")
cartItems CartItem[] @relation("CartItem_channel")
metadata Json?
user User? @relation("Channel_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([platformId])
@@index([userId])
}
model ChannelPlatform {
id String @id @default(cuid())
name String @default("")
appKey String @default("")
appSecret String @default("")
createPurchaseFunction String @default("")
searchProductsFunction String @default("")
getProductFunction String @default("")
getWebhooksFunction String @default("")
deleteWebhookFunction String @default("")
createWebhookFunction String @default("")
cancelPurchaseWebhookHandler String @default("")
createTrackingWebhookHandler String @default("")
oAuthFunction String @default("")
oAuthCallbackFunction String @default("")
channels Channel[] @relation("Channel_platform")
user User? @relation("ChannelPlatform_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([userId])
}
model ChannelItem {
id String @id @default(cuid())
quantity Int?
productId String @default("")
variantId String @default("")
lineItemId String @default("")
price String @default("")
matches Match[] @relation("ChannelItem_matches")
channel Channel? @relation("ChannelItem_channel", fields: [channelId], references: [id])
channelId String? @map("channel")
user User? @relation("ChannelItem_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@unique([quantity, productId, variantId, channelId, userId])
@@index([channelId])
@@index([userId])
}
model Shop {
id String @id @default(cuid())
name String @default("")
domain String @default("")
accessToken String @default("")
linkMode ShopLinkModeType? @default(sequential)
links Link[] @relation("Link_shop")
platform ShopPlatform? @relation("Shop_platform", fields: [platformId], references: [id])
platformId String? @map("platform")
orders Order[] @relation("Order_shop")
shopItems ShopItem[] @relation("ShopItem_shop")
metadata Json?
user User? @relation("Shop_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([platformId])
@@index([userId])
}
model ShopPlatform {
id String @id @default(cuid())
name String @default("")
appKey String @default("")
appSecret String @default("")
orderLinkFunction String @default("")
updateProductFunction String @default("")
getWebhooksFunction String @default("")
deleteWebhookFunction String @default("")
createWebhookFunction String @default("")
searchProductsFunction String @default("")
getProductFunction String @default("")
searchOrdersFunction String @default("")
addTrackingFunction String @default("")
addCartToPlatformOrderFunction String @default("")
cancelOrderWebhookHandler String @default("")
createOrderWebhookHandler String @default("")
oAuthFunction String @default("")
oAuthCallbackFunction String @default("")
shops Shop[] @relation("Shop_platform")
user User? @relation("ShopPlatform_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([userId])
}
model ShopItem {
id String @id @default(cuid())
quantity Int?
productId String @default("")
variantId String @default("")
lineItemId String @default("")
matches Match[] @relation("Match_input")
shop Shop? @relation("ShopItem_shop", fields: [shopId], references: [id])
shopId String? @map("shop")
user User? @relation("ShopItem_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@unique([quantity, productId, variantId, shopId, userId])
@@index([shopId])
@@index([userId])
}
model Match {
id String @id @default(cuid())
input ShopItem[] @relation("Match_input")
output ChannelItem[] @relation("ChannelItem_matches")
user User? @relation("Match_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([userId])
}
model Link {
id String @id @default(cuid())
shop Shop? @relation("Link_shop", fields: [shopId], references: [id])
shopId String? @map("shop")
channel Channel? @relation("Link_channel", fields: [channelId], references: [id])
channelId String? @map("channel")
rank Int?
filters Json?
customWhere Json?
user User? @relation("Link_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([shopId])
@@index([channelId])
@@index([userId])
}
enum ShopLinkModeType {
sequential
simultaneous
}