-- Migration 044 — Fix Cisco 8000 series product_page_url
--
-- The previous scraper run incorrectly stored the NCS-5500 series URL
-- for Cisco 8000-series SP router models (8101-32FH, 8202-32FH, etc).
-- The correct page is the 8000-series family page on Cisco's new /site/ URL scheme.
--
-- After this migration, the image scraper will re-fetch these 35 switches
-- using the updated buildCiscoUrl() which now returns the correct family URL.

-- 1. Clear the wrongly-stored NCS-5500 product_page_url so the scraper rebuilds it
UPDATE switches
SET product_page_url = NULL,
    assets_scraped_at = NULL
WHERE product_page_url = 'https://www.cisco.com/c/en/us/products/routers/network-convergence-system-5500-series/index.html'
  AND image_url IS NULL;

-- 2. Pre-set the correct 8000-series family URL for all 8000-series models without an image
--    so the next scraper run hits the right page immediately
UPDATE switches
SET product_page_url = 'https://www.cisco.com/site/us/en/products/networking/sdwan-routers/8000-series/index.html',
    assets_scraped_at = NULL
WHERE image_url IS NULL
  AND vendor_id = (SELECT id FROM vendors WHERE slug = 'cisco')
  AND model ~ '^8[0-9]{3}';
