feat(categories): implement category management with hierarchical structure and update product association
This commit is contained in:
@@ -45,6 +45,20 @@ model Product {
|
||||
ownerId Int?
|
||||
owner User? @relation(fields: [ownerId], references: [id], onDelete: SetNull)
|
||||
userProducts UserProduct[]
|
||||
categoryId Int?
|
||||
categoryRef Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
|
||||
}
|
||||
|
||||
model Category {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
parentId Int?
|
||||
parent Category? @relation("CategoryTree", fields: [parentId], references: [id], onDelete: SetNull)
|
||||
children Category[] @relation("CategoryTree")
|
||||
products Product[]
|
||||
|
||||
@@unique([name, parentId])
|
||||
@@index([parentId])
|
||||
}
|
||||
|
||||
model UserProduct {
|
||||
|
||||
Reference in New Issue
Block a user