-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
106 lines (91 loc) · 3.51 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
// This file is automatically generated by Keystone, do not modify it manually.
// Modify your Keystone config when you want to change this.
datasource sqlite {
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
provider = "sqlite"
}
generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}
model Product {
id String @id @default(cuid())
name String @default("")
subtitle String @default("")
description String @default("")
photo ProductImage[] @relation("ProductImage_product")
status String? @default("DRAFT")
price Int?
user User? @relation("Product_user", fields: [userId], references: [id])
userId String? @map("user")
from_CartItem_product CartItem[] @relation("CartItem_product")
@@index([userId])
}
model ProductImage {
id String @id @default(cuid())
image String?
altText String @default("")
product Product? @relation("ProductImage_product", fields: [productId], references: [id])
productId String? @map("product")
from_OrderItem_photo OrderItem[] @relation("OrderItem_photo")
@@index([productId])
}
model User {
id String @id @default(cuid())
name String @default("")
email String @unique @default("")
password String
orders Order[] @relation("Order_user")
products Product[] @relation("Product_user")
cart CartItem[] @relation("CartItem_user")
role Role? @relation("User_role", fields: [roleId], references: [id])
roleId String? @map("role")
createdAt DateTime? @default(now())
@@index([roleId])
}
model CartItem {
id String @id @default(cuid())
quantity Int @default(1)
product Product? @relation("CartItem_product", fields: [productId], references: [id])
productId String? @map("product")
user User? @relation("CartItem_user", fields: [userId], references: [id])
userId String? @map("user")
@@index([productId])
@@index([userId])
}
model OrderItem {
id String @id @default(cuid())
name String @default("")
description String @default("")
photo ProductImage? @relation("OrderItem_photo", fields: [photoId], references: [id])
photoId String? @map("photo")
price Int?
quantity Int?
productId String @default("")
order Order? @relation("OrderItem_order", fields: [orderId], references: [id])
orderId String? @map("order")
@@index([photoId])
@@index([orderId])
}
model Order {
id String @id @default(cuid())
total Int?
items OrderItem[] @relation("OrderItem_order")
user User? @relation("Order_user", fields: [userId], references: [id])
userId String? @map("user")
charge String @default("")
createdAt DateTime?
@@index([userId])
}
model Role {
id String @id @default(cuid())
name String @default("")
canManageProducts Boolean @default(false)
canSeeOtherUsers Boolean @default(false)
canManageUsers Boolean @default(false)
canManageRoles Boolean @default(false)
canManageCart Boolean @default(false)
canManageOrders Boolean @default(false)
assignedTo User[] @relation("User_role")
}