-- Add shipping cost column to orders table
ALTER TABLE orders ADD COLUMN IF NOT EXISTS shipping_cost DECIMAL(10, 2) DEFAULT 0.00;

-- Update shipping info to be JSONB if not already
ALTER TABLE orders ALTER COLUMN shipping_info TYPE JSONB
USING CASE
    WHEN shipping_info IS NULL THEN NULL
    WHEN jsonb_typeof(shipping_info::jsonb) = 'object' THEN shipping_info::jsonb
    ELSE jsonb_build_object('data', shipping_info)
END;