-- Add columns for VPSBenchmarks.com scraper
-- Migration: Add metadata columns to vps_benchmarks table

-- Step 1: Add new columns
ALTER TABLE vps_benchmarks ADD COLUMN storage_gb INTEGER;
ALTER TABLE vps_benchmarks ADD COLUMN benchmark_date TEXT;
ALTER TABLE vps_benchmarks ADD COLUMN data_source TEXT DEFAULT 'manual';
ALTER TABLE vps_benchmarks ADD COLUMN validation_status TEXT DEFAULT 'pending';

-- Step 2: Remove duplicates (keep highest geekbench_total for each provider/plan/country)
DELETE FROM vps_benchmarks
WHERE id NOT IN (
  SELECT MAX(id)
  FROM vps_benchmarks
  GROUP BY provider_name, plan_name, country_code
);

-- Step 3: Create unique index for deduplication
CREATE UNIQUE INDEX IF NOT EXISTS idx_vps_benchmarks_unique
ON vps_benchmarks(provider_name, plan_name, country_code);
