-- TIP: Transceiver Intelligence Platform
-- Migration 009: Seed Switch Data
-- Major network switch models from Cisco, Arista, Juniper, Broadcom-based whitebox

-- First ensure vendors exist
INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('Cisco Systems', 'cisco', 'manufacturer', 'San Jose, CA', 'US', 'https://www.cisco.com')
ON CONFLICT (slug) DO NOTHING;

INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('Arista Networks', 'arista', 'manufacturer', 'Santa Clara, CA', 'US', 'https://www.arista.com')
ON CONFLICT (slug) DO NOTHING;

INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('Juniper Networks', 'juniper', 'manufacturer', 'Sunnyvale, CA', 'US', 'https://www.juniper.net')
ON CONFLICT (slug) DO NOTHING;

INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('Edgecore Networks', 'edgecore', 'manufacturer', 'Hsinchu', 'TW', 'https://www.edge-core.com')
ON CONFLICT (slug) DO NOTHING;

INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('Celestica', 'celestica', 'manufacturer', 'Toronto', 'CA', 'https://www.celestica.com')
ON CONFLICT (slug) DO NOTHING;

INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('NVIDIA Networking', 'nvidia-networking', 'manufacturer', 'Santa Clara, CA', 'US', 'https://www.nvidia.com/en-us/networking/')
ON CONFLICT (slug) DO NOTHING;

INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('Dell Technologies', 'dell', 'manufacturer', 'Round Rock, TX', 'US', 'https://www.dell.com')
ON CONFLICT (slug) DO NOTHING;

INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('HPE / Aruba', 'hpe-aruba', 'manufacturer', 'San Jose, CA', 'US', 'https://www.arubanetworks.com')
ON CONFLICT (slug) DO NOTHING;

INSERT INTO vendors (name, slug, type, headquarters, country, website)
VALUES
  ('Asterfusion', 'asterfusion', 'manufacturer', 'Beijing', 'CN', 'https://www.asterfusion.com')
ON CONFLICT (slug) DO NOTHING;

-- Cisco Nexus Data Center
INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support)
SELECT v.id, 'N9K-C9364C', 'Nexus 9300', 'DataCenter', 'L3',
  '{"100G_QSFP28": 64}'::jsonb, 64, 100, 12.8, 4760,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true
FROM vendors v WHERE v.slug = 'cisco';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support)
SELECT v.id, 'N9K-C93600CD-GX', 'Nexus 9300', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 28, "100G_QSFP28": 8}'::jsonb, 36, 400, 12.8, 4760,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true
FROM vendors v WHERE v.slug = 'cisco';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support)
SELECT v.id, 'N9K-C9336C-FX2', 'Nexus 9300', 'DataCenter', 'L3',
  '{"100G_QSFP28": 36}'::jsonb, 36, 100, 7.2, 2680,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true
FROM vendors v WHERE v.slug = 'cisco';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support)
SELECT v.id, 'N9K-C9332D-GX2B', 'Nexus 9300', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 32}'::jsonb, 32, 400, 25.6, 9520,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true
FROM vendors v WHERE v.slug = 'cisco';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, mpls_support)
SELECT v.id, 'N9K-C9508', 'Nexus 9500', 'Core', 'L3',
  '{"400G_QSFP-DD": 576}'::jsonb, 576, 400, 230.4, 85000,
  'Cisco', 'Cloud Scale', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'cisco';

-- Arista 7000 Series
INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, openconfig_support)
SELECT v.id, '7060X6-64PE', 'Arista 7060X', 'DataCenter', 'L3',
  '{"800G_OSFP": 64}'::jsonb, 64, 800, 51.2, 19000,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'arista';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, openconfig_support)
SELECT v.id, '7060X5-64', 'Arista 7060X', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 64}'::jsonb, 64, 400, 51.2, 19000,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'arista';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, openconfig_support)
SELECT v.id, '7050X4-32', 'Arista 7050X', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 32}'::jsonb, 32, 400, 25.6, 9520,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'arista';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, openconfig_support)
SELECT v.id, '7280R3-48YC6', 'Arista 7280R', 'SP', 'L3',
  '{"100G_QSFP28": 6, "25G_SFP28": 48}'::jsonb, 54, 100, 6.4, 2380,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'arista';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, openconfig_support)
SELECT v.id, '7800R3-36P-LC', 'Arista 7800R', 'Core', 'L3',
  '{"400G_QSFP-DD": 36}'::jsonb, 36, 400, 28.8, 10700,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'arista';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, openconfig_support)
SELECT v.id, '7020R', 'Arista 7020R', 'Campus', 'L3',
  '{"1G_SFP": 48, "10G_SFP+": 6}'::jsonb, 54, 10, 0.176, 130,
  'Broadcom', 'Memory Pipeline', 'Active', true, false, false, true
FROM vendors v WHERE v.slug = 'arista';

-- Juniper QFX Series
INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support)
SELECT v.id, 'QFX5130-32CD', 'QFX5100', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 32}'::jsonb, 32, 400, 25.6, 9520,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true
FROM vendors v WHERE v.slug = 'juniper';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support)
SELECT v.id, 'QFX5220-32CD', 'QFX5200', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 32}'::jsonb, 32, 400, 25.6, 9520,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true
FROM vendors v WHERE v.slug = 'juniper';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support)
SELECT v.id, 'QFX5120-48Y', 'QFX5100', 'DataCenter', 'L3',
  '{"25G_SFP28": 48, "100G_QSFP28": 8}'::jsonb, 56, 100, 4.0, 1488,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true
FROM vendors v WHERE v.slug = 'juniper';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, mpls_support)
SELECT v.id, 'QFX10008', 'QFX10000', 'Core', 'L3',
  '{"400G_QSFP-DD": 288}'::jsonb, 288, 400, 115.2, 42800,
  'Juniper', 'ExpressPlus', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'juniper';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, lifecycle_status, bgp_support, vxlan_support, evpn_support)
SELECT v.id, 'EX4400-48T', 'EX4400', 'Campus', 'L3',
  '{"1G_RJ45": 48, "10G_SFP+": 4, "25G_SFP28": 2}'::jsonb, 54, 25, 1.76, 654,
  'Broadcom', 'Active', true, true, true
FROM vendors v WHERE v.slug = 'juniper';

-- NVIDIA / Mellanox Spectrum
INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, sonic_compatible)
SELECT v.id, 'SN5600', 'Spectrum-4', 'DataCenter', 'L3',
  '{"800G_OSFP": 64}'::jsonb, 64, 800, 51.2, 19000,
  'NVIDIA', 'Spectrum-4', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'nvidia-networking';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, sonic_compatible)
SELECT v.id, 'SN4700', 'Spectrum-3', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 32}'::jsonb, 32, 400, 12.8, 4760,
  'NVIDIA', 'Spectrum-3', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'nvidia-networking';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, forwarding_rate_mpps, asic_vendor, asic_model, lifecycle_status, bgp_support, vxlan_support, evpn_support, sonic_compatible)
SELECT v.id, 'SN3700', 'Spectrum-2', 'DataCenter', 'L3',
  '{"100G_QSFP28": 32}'::jsonb, 32, 100, 6.4, 2380,
  'NVIDIA', 'Spectrum-2', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'nvidia-networking';

-- Edgecore Whitebox
INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, asic_vendor, asic_model, lifecycle_status, sonic_compatible, is_whitebox, onie_support, bgp_support)
SELECT v.id, 'DCS810', 'AS9516-32D', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 32}'::jsonb, 32, 400, 12.8,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'edgecore';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, asic_vendor, asic_model, lifecycle_status, sonic_compatible, is_whitebox, onie_support, bgp_support)
SELECT v.id, 'AS7726-32X', 'AS7726', 'DataCenter', 'L3',
  '{"100G_QSFP28": 32}'::jsonb, 32, 100, 6.4,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'edgecore';

-- Celestica
INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, asic_vendor, asic_model, lifecycle_status, sonic_compatible, is_whitebox, onie_support, bgp_support)
SELECT v.id, 'DS5000', 'Seastone', 'DataCenter', 'L3',
  '{"800G_OSFP": 64}'::jsonb, 64, 800, 51.2,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'celestica';

INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, asic_vendor, asic_model, lifecycle_status, sonic_compatible, is_whitebox, onie_support, bgp_support)
SELECT v.id, 'DS3000', 'Seastone', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 32}'::jsonb, 32, 400, 12.8,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'celestica';

-- Asterfusion
INSERT INTO switches (vendor_id, model, series, category, layer, ports_config, total_ports, max_speed_gbps, switching_capacity_tbps, asic_vendor, asic_model, lifecycle_status, sonic_compatible, is_whitebox, onie_support, bgp_support)
SELECT v.id, 'CX864E-N', 'CX8000', 'DataCenter', 'L3',
  '{"400G_QSFP-DD": 64}'::jsonb, 64, 400, 25.6,
  'Broadcom', 'Memory Pipeline', 'Active', true, true, true, true
FROM vendors v WHERE v.slug = 'asterfusion';

-- Generate search vectors for switches
UPDATE switches SET search_vector = to_tsvector('english',
  coalesce(model, '') || ' ' ||
  coalesce(series, '') || ' ' ||
  coalesce(category, '') || ' ' ||
  coalesce(asic_vendor, '') || ' ' ||
  coalesce(asic_model, '')
)
WHERE search_vector IS NULL;
