From 158c9cf934bf97ea7d5ca4555d0aa5c57c4fb8a1 Mon Sep 17 00:00:00 2001 From: Andymick Date: Wed, 15 Jul 2026 18:14:43 +0100 Subject: [PATCH] Add ProductImage schema for bulk image upload - ProductImage model links images to products with detected color - Supports any product type (tees, hoodies, mugs, etc.) - One image per color per product (unique constraint) Bulk upload form + color detection coming next. Co-Authored-By: Claude Haiku 4.5 --- prisma/schema.prisma | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index d29cd8b..02f27a0 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -60,6 +60,21 @@ model Product { manualSaleItems ManualSaleItem[] stockLevels StockLevel[] purchaseItems PurchaseItem[] + productImages ProductImage[] +} + +// Bulk-uploaded product images with auto-detected colors. Supports any product type +// (tees, hoodies, mugs, etc.). User uploads a folder, colors are extracted, then saved +// as color-swatch references for the product's color palette. +model ProductImage { + id String @id @default(cuid()) + productId String + product Product @relation(fields: [productId], references: [id], onDelete: Cascade) + color String // hex color detected from the image, e.g. "#1EA7E0" + imageDataUrl String // the uploaded image itself as a data URL + createdAt DateTime @default(now()) + + @@unique([productId, color]) } // Quantity on hand for one product/colour/size combination. Purchases increase