-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
134 lines (121 loc) · 4.88 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
// This is your Prisma schema file,
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator erd {
provider = "prisma-erd-generator"
theme = "forest"
output = "../ERD.svg"
}
model Business {
id String @id @default(uuid())
businessName String
email String @unique
password String
sellers Seller[] @relation("businessSellers")
products Product[] @relation("businessProducts")
clients Client[] @relation("businessClient")
orders Order[] @relation("orderBusiness")
orderItems OrderItem[] @relation("orderItems_business")
created_at DateTime?
deleted_at DateTime?
}
model Seller {
id String @id @default(uuid())
userName String?
email String @unique
password String
business Business @relation("businessSellers", fields: [businessId], references: [id])
businessId String
orderItems OrderItem[] @relation("orderItems_seller")
isAdmin Boolean
clients Client[] @relation("sellerClient")
}
model Product {
id String @id @default(uuid())
productStock ProductStock? @relation("productStock", fields: [productStockId], references: [id])
productStockId String? @unique
description String
salePrice Float
coastPrice Float
business Business @relation("businessProducts", fields: [businessId], references: [id])
businessId String
created_at DateTime?
deleted_at DateTime?
@@map("products")
}
model ProductStock {
id String @id @default(uuid())
product Product? @relation("productStock")
productId String @unique
unityMeasurement UnityMeasurement
currentInventory Int
previousStock Int?
currentWeight Float?
previousWeight Float?
lastSale DateTime?
lastEntry DateTime?
lastModification DateTime?
lastEntryLogin String?
lastSaleLogin String?
deleted_at DateTime?
@@map("product_stocks")
}
enum UnityMeasurement {
L
M
KG
UN
}
model Client {
id String @id @default(uuid())
name String
orders Order[] @relation("clientOrder")
clientContact ClientContact? @relation("clientContact")
clientContactId String? @unique
seller Seller? @relation("sellerClient", fields: [sellerId], references: [id])
sellerId String?
business Business @relation("businessClient", fields: [businessId], references: [id])
businessId String
created_at DateTime?
deleted_at DateTime?
@@map("clients")
}
model ClientContact {
id String @id @default(uuid())
client Client @relation("clientContact", fields: [clientId], references: [id])
clientId String @unique
city String
zipCode String
state String
neighborhood String
numberHouse String @unique
cellphoneNumber String
}
model OrderItem {
id String @id @default(uuid())
productName String
order Order @relation("orderItems", fields: [orderId], references: [id])
orderId String
amount Int
subtotal Float
seller Seller @relation("orderItems_seller", fields: [sellerId], references: [id])
sellerId String
business Business @relation("orderItems_business", fields: [businessId], references: [id])
businessId String
}
model Order {
id String @id @default(uuid())
client Client @relation("clientOrder", fields: [clientId], references: [id])
clientId String
business Business @relation("orderBusiness", fields: [businessId], references: [id])
businessId String @unique
orderItems OrderItem[] @relation("orderItems")
created_at DateTime?
deleted_at DateTime?
totalOrder Float
}