From 4bad1ba5f116256c6cab8d2facca60590a9cf2f4 Mon Sep 17 00:00:00 2001 From: alexNg Date: Mon, 17 Feb 2025 21:29:56 +0700 Subject: [PATCH] task abc --- prisma/dbml/schema.dbml | 15 +++++++++------ prisma/schema.prisma | 21 +++++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/prisma/dbml/schema.dbml b/prisma/dbml/schema.dbml index 1b1a6bd..aba6b0e 100644 --- a/prisma/dbml/schema.dbml +++ b/prisma/dbml/schema.dbml @@ -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] } } @@ -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 diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7418ad8..3c53f05 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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 {