feat(categories): implement category management with hierarchical structure and update product association

This commit is contained in:
Nils-Johan Gynther
2026-04-17 21:16:58 +02:00
parent a9e83544c5
commit cc8be88462
11 changed files with 286 additions and 42 deletions
+14
View File
@@ -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 {