x
This commit is contained in:
1 parent
1c0313495f
commit
ac387185e0
15 files changed
+1855
-12
No files matched your search
@@ -35,6 +35,7 @@ model Category {
|
||||
name String @unique
|
||||
imageUrl String?
|
||||
products Product[]
|
||||
attributes AttributeDefinition[]
|
||||
translations CategoryTranslation[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -65,6 +66,7 @@ model Product {
|
||||
options Json? @default("[]") // Expected shape: [{ name: "Color", values: ["Red", "Blue"] }, ...]
|
||||
variants ProductVariant[]
|
||||
images ProductImage[]
|
||||
attributes ProductAttribute[]
|
||||
reviews Review[]
|
||||
translations ProductTranslation[]
|
||||
createdAt DateTime @default(now())
|
||||
@@ -113,6 +115,73 @@ model ProductVariant {
|
||||
@@unique([productId, option1, option2, option3])
|
||||
}
|
||||
|
||||
model AttributeDefinition {
|
||||
id Int @id @default(autoincrement())
|
||||
code String @unique
|
||||
label String
|
||||
description String?
|
||||
type String // TEXT, NUMBER, BOOLEAN, SELECT, JSON
|
||||
unit String?
|
||||
options Json? // Expected shape: [{ value: "floral", label: { th: "ดอกไม้", en: "Floral" } }]
|
||||
isRequired Boolean @default(false)
|
||||
isFilterable Boolean @default(false)
|
||||
sortOrder Int @default(0)
|
||||
categoryId Int?
|
||||
category Category? @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
||||
products ProductAttribute[]
|
||||
translations AttributeDefinitionTranslation[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([categoryId])
|
||||
@@index([sortOrder])
|
||||
}
|
||||
|
||||
model AttributeDefinitionTranslation {
|
||||
id Int @id @default(autoincrement())
|
||||
attributeDefinitionId Int
|
||||
attributeDefinition AttributeDefinition @relation(fields: [attributeDefinitionId], references: [id], onDelete: Cascade)
|
||||
langCode String
|
||||
label String
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([attributeDefinitionId, langCode])
|
||||
}
|
||||
|
||||
model ProductAttribute {
|
||||
id Int @id @default(autoincrement())
|
||||
productId Int
|
||||
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
||||
attributeDefinitionId Int
|
||||
attributeDefinition AttributeDefinition @relation(fields: [attributeDefinitionId], references: [id], onDelete: Cascade)
|
||||
valueText String?
|
||||
valueNumber Float?
|
||||
valueBoolean Boolean?
|
||||
valueJson Json?
|
||||
translations ProductAttributeTranslation[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([productId, attributeDefinitionId])
|
||||
@@index([productId])
|
||||
@@index([attributeDefinitionId])
|
||||
}
|
||||
|
||||
model ProductAttributeTranslation {
|
||||
id Int @id @default(autoincrement())
|
||||
productAttributeId Int
|
||||
productAttribute ProductAttribute @relation(fields: [productAttributeId], references: [id], onDelete: Cascade)
|
||||
langCode String
|
||||
valueText String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([productAttributeId, langCode])
|
||||
@@index([productAttributeId])
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
username String @unique
|
||||
|
||||
Reference in new issue
Block a user