-- Migration: Add barcode column to products table
-- Date: 2026-02-04
-- Description: Adds barcode field for scanner integration

-- Add barcode column (nullable, unique)
ALTER TABLE products
ADD COLUMN barcode VARCHAR(255) NULL UNIQUE;

-- Add index for faster barcode lookups
CREATE INDEX idx_products_barcode ON products(barcode);

-- Optional: Update existing products with sample barcodes (remove if not needed)
-- UPDATE products SET barcode = CONCAT('BAR', LPAD(id, 10, '0')) WHERE barcode IS NULL;

-- Verification query
-- SELECT COUNT(*) as products_with_barcodes FROM products WHERE barcode IS NOT NULL;
