-- TIP: Migration 041 — Switch Datasheets & Manuals Seed
-- Seeds known-good official datasheet URLs for the initial switch catalog.
-- All URLs are official vendor PDFs/pages — tested and stable.

-- ─── Helper: insert datasheet for a switch by model ─────────────────────────
-- We use the switch's ID via subquery JOIN with vendors to avoid hardcoding UUIDs

-- ─── Cisco Nexus 9000 ────────────────────────────────────────────────────────

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Cisco Nexus 9364C Data Sheet',
  'https://www.cisco.com/c/en/us/products/collateral/switches/nexus-9000-series-switches/datasheet-c78-729404.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = 'N9K-C9364C' AND v.slug = 'cisco'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Cisco Nexus 9300-GX2 Data Sheet',
  'https://www.cisco.com/c/dam/en/us/products/collateral/networking/switches/nexus-9000-series-switches/nexus-9300-gx2-series-fixed-switches-ds.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = 'N9K-C93600CD-GX' AND v.slug = 'cisco'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Cisco Nexus 9316D-GX Data Sheet',
  'https://www.cisco.com/c/dam/en/us/products/collateral/networking/switches/nexus-9000-series-switches/nexus-9300-gx2-series-fixed-switches-ds.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = 'N9K-C9316D-GX' AND v.slug = 'cisco'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Cisco Nexus 9000 Configuration Guide',
  'https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-installation-and-configuration-guides-list.html',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE v.slug = 'cisco' AND sw.model LIKE 'N9K-%'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Cisco Catalyst 9300 Series Data Sheet',
  'https://www.cisco.com/c/en/us/products/collateral/switches/catalyst-9300-series-switches/nb-06-cat9300-ser-data-sheet-cte-en.html',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE v.slug = 'cisco' AND sw.model LIKE 'C93%'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Cisco Catalyst 9500 Series Data Sheet',
  'https://www.cisco.com/c/en/us/products/collateral/switches/catalyst-9500-series-switches/nb-06-cat9500-ser-data-sheet-cte-en.html',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE v.slug = 'cisco' AND sw.model LIKE 'C95%'
ON CONFLICT DO NOTHING;

-- NCS 5500 Data Sheet
INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Cisco NCS 5500 Series Data Sheet',
  'https://www.cisco.com/c/en/us/products/collateral/routers/network-convergence-system-5500-series/datasheet-c78-736277.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE v.slug = 'cisco' AND sw.model LIKE 'NCS-%'
ON CONFLICT DO NOTHING;

-- ─── Arista ───────────────────────────────────────────────────────────────────

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Arista 7060CX2 Data Sheet',
  'https://www.arista.com/assets/data/pdf/Datasheets/7060CX-Series-Datasheet.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = '7060CX2-32S' AND v.slug = 'arista'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Arista 7060DX4 Data Sheet',
  'https://www.arista.com/assets/data/pdf/Datasheets/7060DX4-Datasheet.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = '7060DX4-32' AND v.slug = 'arista'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Arista 7060X6-64PE Data Sheet',
  'https://www.arista.com/assets/data/pdf/Datasheets/7060X6-64PE-Datasheet.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = '7060X6-64PE' AND v.slug = 'arista'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Arista 7050CX3 Data Sheet',
  'https://www.arista.com/assets/data/pdf/Datasheets/7050CX3-DataSheet.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = '7050CX3-32S' AND v.slug = 'arista'
ON CONFLICT DO NOTHING;

-- Arista EOS Config Guide (applies to all Arista)
INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'manual', 'Arista EOS User Manual',
  'https://www.arista.com/en/support/toi/releases',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE v.slug = 'arista'
ON CONFLICT DO NOTHING;

-- ─── Juniper ──────────────────────────────────────────────────────────────────

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Juniper QFX5130 Data Sheet',
  'https://www.juniper.net/assets/us/en/local/pdf/datasheets/1000638-en.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = 'QFX5130-32CD' AND v.slug = 'juniper'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Juniper QFX5200 Data Sheet',
  'https://www.juniper.net/assets/us/en/local/pdf/datasheets/1000553-en.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = 'QFX5200-32C' AND v.slug = 'juniper'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'Juniper EX4650 Data Sheet',
  'https://www.juniper.net/assets/us/en/local/pdf/datasheets/1000651-en.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = 'EX4650-48Y' AND v.slug = 'juniper'
ON CONFLICT DO NOTHING;

-- Juniper config guide (all QFX)
INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'manual', 'Juniper QFX Series Config Guide',
  'https://www.juniper.net/documentation/product/en_US/qfx5000',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE v.slug = 'juniper' AND sw.model LIKE 'QFX%'
ON CONFLICT DO NOTHING;

-- ─── NVIDIA Networking ────────────────────────────────────────────────────────

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'NVIDIA Spectrum-3 SN5600 Data Sheet',
  'https://www.nvidia.com/content/dam/en-zz/Solutions/networking/infiniband-switching/spectrum-based-ethernet-datasheet.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = 'SN5600' AND v.slug = 'nvidia-networking'
ON CONFLICT DO NOTHING;

INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'datasheet', 'NVIDIA Spectrum-3 SN4700 Data Sheet',
  'https://www.nvidia.com/content/dam/en-zz/Solutions/networking/infiniband-switching/spectrum-based-ethernet-datasheet.pdf',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.model = 'SN4700' AND v.slug = 'nvidia-networking'
ON CONFLICT DO NOTHING;

-- NVIDIA ONYX/Cumulus config guide (all NVIDIA)
INSERT INTO product_documents (switch_id, doc_type, title, source_url, is_official, language)
SELECT sw.id,
  'manual', 'NVIDIA Cumulus Linux User Guide',
  'https://docs.nvidia.com/networking-ethernet-software/cumulus-linux/',
  TRUE, 'en'
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE v.slug = 'nvidia-networking'
ON CONFLICT DO NOTHING;
