Files
craft2prints/DATABASE_OPTIMIZATION_MIGRATION.sql
T
AndymickandClaude Haiku 4.5 16f1f64fd0 Feature: Add customer reviews system with admin management
- Add Review model to database with approval workflow
- Customers can submit reviews with 1-5 star ratings
- Admin can approve, reject, or delete reviews
- Public reviews page showing all approved reviews with rating stats
- ReviewForm component for easy integration on product pages
- Bulk gallery upload now properly tracked

Chore: Add expected delivery date for design approvals

- Add expectedDeliveryDate field to DesignApproval model
- Admin can set delivery date when approving designs
- Improves customer communication and expectations

Chore: Add welcome back message for logged-in customers

- Display personalized greeting on account page after login
- Shows customer's name if available

Chore: Add color difference disclaimer to product pages

- Added to StandardProductView (ready-made products)
- Added to DesignCanvas (personalized products)
- Informs customers about lighting-based color variations
- Helps manage customer expectations

Feature: Add image identification in design specifications

- Images now clearly labeled as "Image 1", "Image 2", etc.
- Images marked with purple circles in specification diagrams
- Improves clarity for production team

Documentation: Add comprehensive database optimization guide

- DATABASE_OPTIMIZATION.md - Full optimization strategies
- DATABASE_OPTIMIZATION_QUICK_START.md - Implementation examples
- DATABASE_OPTIMIZATION_MIGRATION.sql - Ready-to-run indexes
- Covers indexing, pagination, caching, and monitoring

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 18:24:58 +01:00

40 lines
1.8 KiB
SQL

-- Database Performance Optimization Indexes
-- Run this directly on PostgreSQL or use: npx prisma db execute --stdin < DATABASE_OPTIMIZATION_MIGRATION.sql
-- Order indexes
CREATE INDEX IF NOT EXISTS idx_order_customer_created ON "Order"("customerId", "createdAt" DESC);
CREATE INDEX IF NOT EXISTS idx_order_status_created ON "Order"("status", "createdAt" DESC);
CREATE INDEX IF NOT EXISTS idx_order_email ON "Order"("email");
-- OrderItem indexes
CREATE INDEX IF NOT EXISTS idx_order_item_order_product ON "OrderItem"("orderId", "productId");
CREATE INDEX IF NOT EXISTS idx_order_item_product ON "OrderItem"("productId");
-- DesignApproval indexes
CREATE INDEX IF NOT EXISTS idx_design_approval_email_status ON "DesignApproval"("customerEmail", "status");
CREATE INDEX IF NOT EXISTS idx_design_approval_status_created ON "DesignApproval"("status", "createdAt" DESC);
CREATE INDEX IF NOT EXISTS idx_design_approval_product ON "DesignApproval"("productId");
-- Review indexes
CREATE INDEX IF NOT EXISTS idx_review_product_approved ON "Review"("productId", "approved");
CREATE INDEX IF NOT EXISTS idx_review_customer ON "Review"("customerId");
-- Product indexes
CREATE INDEX IF NOT EXISTS idx_product_category_visible ON "Product"("category", "showOnProducts");
CREATE INDEX IF NOT EXISTS idx_product_personalised ON "Product"("showOnPersonalised");
-- DesignProof indexes
CREATE INDEX IF NOT EXISTS idx_design_proof_status ON "DesignProof"("status", "createdAt" DESC);
-- Message indexes
CREATE INDEX IF NOT EXISTS idx_message_proof ON "Message"("proofId", "createdAt");
-- Customer indexes
CREATE INDEX IF NOT EXISTS idx_customer_email ON "Customer"("email");
-- Gallery Photo indexes
CREATE INDEX IF NOT EXISTS idx_gallery_photo_approved ON "GalleryPhoto"("approved", "createdAt" DESC);
-- Optimize query planner statistics
ANALYZE;