-- Migration 003: Add Retail Pricing Fields
-- Description: Add hourly_price_retail and monthly_price_retail to all pricing tables
-- Date: 2026-01-23
-- Author: Claude Code

-- ============================================================
-- Add retail pricing columns to pricing table
-- ============================================================

ALTER TABLE pricing ADD COLUMN hourly_price_retail REAL;
ALTER TABLE pricing ADD COLUMN monthly_price_retail REAL;

-- Backfill existing data with retail prices (wholesale × 1.21)
UPDATE pricing
SET
  hourly_price_retail = ROUND(hourly_price * 1.21 * 10000) / 10000,
  monthly_price_retail = ROUND(monthly_price * 1.21 * 100) / 100
WHERE hourly_price_retail IS NULL;

-- ============================================================
-- Add retail pricing columns to gpu_pricing table
-- ============================================================

ALTER TABLE gpu_pricing ADD COLUMN hourly_price_retail REAL;
ALTER TABLE gpu_pricing ADD COLUMN monthly_price_retail REAL;

-- Backfill existing data with retail prices (wholesale × 1.21)
UPDATE gpu_pricing
SET
  hourly_price_retail = ROUND(hourly_price * 1.21 * 10000) / 10000,
  monthly_price_retail = ROUND(monthly_price * 1.21 * 100) / 100
WHERE hourly_price_retail IS NULL;

-- ============================================================
-- Add retail pricing columns to g8_pricing table
-- ============================================================

ALTER TABLE g8_pricing ADD COLUMN hourly_price_retail REAL;
ALTER TABLE g8_pricing ADD COLUMN monthly_price_retail REAL;

-- Backfill existing data with retail prices (wholesale × 1.21)
UPDATE g8_pricing
SET
  hourly_price_retail = ROUND(hourly_price * 1.21 * 10000) / 10000,
  monthly_price_retail = ROUND(monthly_price * 1.21 * 100) / 100
WHERE hourly_price_retail IS NULL;

-- ============================================================
-- Add retail pricing columns to vpu_pricing table
-- ============================================================

ALTER TABLE vpu_pricing ADD COLUMN hourly_price_retail REAL;
ALTER TABLE vpu_pricing ADD COLUMN monthly_price_retail REAL;

-- Backfill existing data with retail prices (wholesale × 1.21)
UPDATE vpu_pricing
SET
  hourly_price_retail = ROUND(hourly_price * 1.21 * 10000) / 10000,
  monthly_price_retail = ROUND(monthly_price * 1.21 * 100) / 100
WHERE hourly_price_retail IS NULL;
