From d8dcaa51c97ff77cadb90ce38451be326ffe45d0 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Sat, 4 Oct 2025 14:46:32 +0100 Subject: [PATCH] Migration: Add variant pricing support to database schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Critical fix for production deployment issue where code changes were deployed without corresponding database schema updates. Changes: - Add Price column to ProductVariants table (decimal 18,2, nullable) - Add ProductVariantId column to OrderItems table (TEXT, nullable) - Add index on OrderItems.ProductVariantId for query performance This migration was manually applied to production on 2025-10-04 to resolve "no such column: p2.Price" errors that broke the product catalog API. Future deployments must include database migration steps in CI/CD. 🤖 Generated with Claude Code https://claude.com/claude-code Co-Authored-By: Claude --- LittleShop/Migrations/AddVariantPricing.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 LittleShop/Migrations/AddVariantPricing.sql diff --git a/LittleShop/Migrations/AddVariantPricing.sql b/LittleShop/Migrations/AddVariantPricing.sql new file mode 100644 index 0000000..7305a71 --- /dev/null +++ b/LittleShop/Migrations/AddVariantPricing.sql @@ -0,0 +1,17 @@ +-- Migration: Add Variant Pricing Support +-- Date: 2025-10-03 +-- Description: Adds Price field to ProductVariants table and ProductVariantId to OrderItems table + +-- Add Price column to ProductVariants table +ALTER TABLE ProductVariants ADD COLUMN Price decimal(18,2) NULL; + +-- Add ProductVariantId column to OrderItems table +ALTER TABLE OrderItems ADD COLUMN ProductVariantId TEXT NULL; + +-- Add index on ProductVariantId for performance +CREATE INDEX IF NOT EXISTS IX_OrderItems_ProductVariantId ON OrderItems (ProductVariantId); + +-- Migration complete +-- No data migration needed - existing records will have NULL values which is correct +-- Variant Price defaults to NULL (uses product base price) +-- OrderItems ProductVariantId defaults to NULL (no variant selected)