-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
63 lines (56 loc) · 1.54 KB
/
schema.prisma
File metadata and controls
63 lines (56 loc) · 1.54 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
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
name String
email String @unique
orders Order[]
createdAt DateTime @default(now())
}
model Restaurant {
id Int @id @default(autoincrement())
name String
address String
menu MenuItem[]
Order Order[]
}
model MenuItem {
id Int @id @default(autoincrement())
restaurant Restaurant @relation(fields: [restaurantId], references: [id])
restaurantId Int
name String
price Decimal @db.Decimal(7, 2)
available Boolean @default(true)
OrderItem OrderItem[]
}
model Order {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
restaurant Restaurant @relation(fields: [restaurantId], references: [id])
restaurantId Int
items OrderItem[]
total Decimal @db.Decimal(9, 2)
status OrderStatus @default(PENDING)
placedAt DateTime @default(now())
}
model OrderItem {
id Int @id @default(autoincrement())
order Order @relation(fields: [orderId], references: [id])
orderId Int
menuItem MenuItem @relation(fields: [menuItemId], references: [id])
menuItemId Int
quantity Int @default(1)
unitPrice Decimal @db.Decimal(7, 2)
}
enum OrderStatus {
PENDING
CONFIRMED
DELIVERED
CANCELLED
}