-- Migration: Enhance Product Color Variants with Pricing and Stock
-- Created: 2025-12-19
-- Description: Adds color code, per-variant pricing, and stock to product_images table

-- Add new columns to product_images table for color variants
ALTER TABLE product_images 
ADD COLUMN IF NOT EXISTS color_code VARCHAR(7), -- Hex color code (e.g., #FF0000)
ADD COLUMN IF NOT EXISTS variant_price DECIMAL(10,2), -- Optional variant-specific price
ADD COLUMN IF NOT EXISTS variant_stock INTEGER DEFAULT 0; -- Stock quantity for this variant

-- Create index for color code lookups
CREATE INDEX IF NOT EXISTS idx_product_images_color_code ON product_images(color_code);

-- Add comments for documentation
COMMENT ON COLUMN product_images.color_code IS 'Hex color code for the variant (e.g., #FF0000 for red)';
COMMENT ON COLUMN product_images.variant_price IS 'Optional price override for this specific color variant';
COMMENT ON COLUMN product_images.variant_stock IS 'Stock quantity available for this specific color variant';
