Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions prisma/dbml/schema.dbml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,24 @@ Table Drink {

Table BestSeller {
id Int [pk, increment]
productId Int [not null]
drinkId Int [not null]
storeId Int [not null]
Drink Drink [not null]
Store Store [not null]

indexes {
(drinkId, storeId) [unique]
}
}

Table Pricing {
productId Int [not null]
drinkId Int [not null]
size Size [not null]
price Decimal [not null]
Drink Drink [not null]

indexes {
(productId, size) [pk]
(productId, size) [unique]
(drinkId, size) [pk]
}
}

Expand Down Expand Up @@ -83,11 +86,11 @@ Enum InfoType {

Ref: Drink.storeId > Store.id

Ref: BestSeller.productId > Drink.id
Ref: BestSeller.drinkId > Drink.id

Ref: BestSeller.storeId > Store.id

Ref: Pricing.productId > Drink.id
Ref: Pricing.drinkId > Drink.id

Ref: Topping.storeId > Store.id

Expand Down
21 changes: 11 additions & 10 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,24 @@ model Drink {
}

model BestSeller {
id Int @id @default(autoincrement()) // key: id
productId Int
storeId Int
id Int @id @default(autoincrement()) // key: id
drinkId Int
storeId Int

Drink Drink @relation(fields: [productId], references: [id])
Drink Drink @relation(fields: [drinkId], references: [id])
Store Store @relation(fields: [storeId], references: [id])

@@unique([drinkId, storeId])
}

model Pricing {
productId Int
size Size
price Decimal @db.Decimal(10, 2)
drinkId Int
size Size
price Decimal @db.Decimal(10, 2)

Drink Drink @relation(fields: [productId], references: [id])
Drink Drink @relation(fields: [drinkId], references: [id])

@@id([productId, size])
@@unique([productId, size])
@@id([drinkId, size])
}

model Topping {
Expand Down