-- Migration 101: Form Factors Reference Table
-- ─────────────────────────────────────────────────────────────────────────────
-- Comprehensive form factor reference with plain-language descriptions,
-- physical dimensions, max speeds, and connector types.
--
-- Covers all 20 form factors in the transceivers table + additional modern ones
-- ─────────────────────────────────────────────────────────────────────────────

CREATE TABLE IF NOT EXISTS form_factors (
  id               UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name             TEXT NOT NULL UNIQUE,           -- e.g. "QSFP28"
  full_name        TEXT NOT NULL,                  -- e.g. "Quad Small Form-factor Pluggable 28"
  short_name       TEXT,                            -- e.g. "QSFP28" (alias/marketing name)
  generation       TEXT,                            -- e.g. "4th generation SFP family"
  family           TEXT,                            -- e.g. "SFP family" | "QSFP family" | "CFP family" | "legacy"
  max_speed_gbps   NUMERIC,                         -- maximum electrical interface speed
  channels         INTEGER,                         -- number of electrical channels (lanes)
  channel_rate_gbps NUMERIC,                        -- per-channel speed in Gbps
  physical_width_mm NUMERIC,                        -- width in mm
  physical_height_mm NUMERIC,                       -- height (depth) in mm
  hot_swap         BOOLEAN DEFAULT TRUE,            -- supports hot-swap / hot-pluggable
  connector_type   TEXT,                            -- typical fiber connector, e.g. "LC duplex", "MPO-12", "varies"
  year_introduced  INTEGER,                         -- year first modules appeared on market
  supersedes       TEXT[] DEFAULT '{}',             -- form factors this one replaces
  superseded_by    TEXT,                            -- newer form factor that replaces this one
  status           TEXT DEFAULT 'current' CHECK (status IN ('current','legacy','emerging','obsolete')),
  description      TEXT,                            -- plain-language explanation (DE · EN)
  notes            TEXT,                            -- technical notes
  url              TEXT,                            -- standard/MSA spec URL
  created_at       TIMESTAMPTZ DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_form_factors_family ON form_factors (family);
CREATE INDEX IF NOT EXISTS idx_form_factors_max_speed ON form_factors (max_speed_gbps DESC);
CREATE INDEX IF NOT EXISTS idx_form_factors_status ON form_factors (status);

-- ─────────────────────────────────────────────────────────────────────────────
-- Insert all known form factors
-- ─────────────────────────────────────────────────────────────────────────────

INSERT INTO form_factors (name, full_name, family, generation, max_speed_gbps, channels, channel_rate_gbps, physical_width_mm, physical_height_mm, hot_swap, connector_type, year_introduced, supersedes, superseded_by, status, description, notes, url)
VALUES

-- ─────────────────────────────
-- SFP Family
-- ─────────────────────────────
('SFP',
 'Small Form-factor Pluggable',
 'SFP family', '1st generation',
 1, 1, 1.0625, 13.4, 56.5, TRUE, 'LC duplex', 2000,
 '{}', 'SFP+', 'legacy',
 'Das Original-Netzwerkmodul — der "USB-Stick" der Netzwerktechnik. Klein, steckbar, für 1G-Verbindungen. Läuft in fast jedem Switch und Router. Zwei Varianten: für Glasfaser (mit Kabel) oder Kupfer (SFP-T, kein Kabel nötig). // The original "thumb drive" of networking. Small, hot-swappable, 1G. Runs in virtually every switch and router ever made. Available for fiber (requires cable) or copper (SFP-T, RJ45 socket).',
 'LC Duplex fiber or RJ45 (SFP-T). Defined by SFF Committee SFF-8472.',
 'https://www.snia.org/technology-communities/sff'),

('SFP+',
 'Small Form-factor Pluggable Plus',
 'SFP family', '2nd generation',
 10, 1, 10.3125, 13.4, 56.5, TRUE, 'LC duplex', 2006,
 '{SFP,XFP}', 'SFP28', 'current',
 'Die 10G-Version des klassischen SFP. Gleiche physische Größe und gleicher Slot wie das Original-SFP — einfaches Upgrade auf 10G ohne neuen Switch. Der meistverkaufte Transceiver-Typ weltweit. // The 10G evolution of the original SFP. Same physical size and slot as the original — direct upgrade to 10G without changing the switch. The world''s best-selling transceiver form factor.',
 'Backward compatible slot with SFP (1G). IEEE 802.3ae. SFF-8431.',
 'https://www.snia.org/technology-communities/sff'),

('SFP28',
 'Small Form-factor Pluggable 28 (25G)',
 'SFP family', '3rd generation',
 25, 1, 25.78125, 13.4, 56.5, TRUE, 'LC duplex', 2016,
 '{SFP+}', 'SFP56', 'current',
 '25G in der SFP-Gehäusegröße. Der Standardanschluss für Server-Netzwerkkarten seit 2017. Läuft im selben physischen Slot wie SFP+ — Switch-Ports können je nach Bedarf 10G oder 25G module aufnehmen. // 25G in the standard SFP housing. The default server NIC connection since 2017. Fits the same physical slot as SFP+ — switch ports can accept either 10G or 25G modules depending on need.',
 'IEEE 802.3by. Same mechanical cage as SFP/SFP+. Dominant server uplink form factor.',
 'https://www.snia.org/technology-communities/sff'),

('SFP56',
 'Small Form-factor Pluggable 56 (50G)',
 'SFP family', '4th generation',
 50, 1, 53.125, 13.4, 56.5, TRUE, 'LC duplex', 2020,
 '{SFP28}', 'SFP112', 'current',
 '50G in SFP-Größe, mit PAM4-Signaltechnik. Für Netzwerke die 50G pro Port benötigen ohne auf größere Module wechseln zu müssen. Noch nicht weit verbreitet — SFP28 (25G) und QSFP28 (100G) dominieren. // 50G in SFP size using PAM4 signaling. For networks needing 50G per port without switching to larger modules. Not yet widely deployed — SFP28 (25G) and QSFP28 (100G) dominate.',
 'PAM4 modulation. IEEE 802.3cd. Backward compatible cage with SFP/SFP+/SFP28.',
 'https://www.snia.org/technology-communities/sff'),

('SFP112',
 'Small Form-factor Pluggable 112 (100G)',
 'SFP family', '5th generation',
 100, 1, 112.0, 13.4, 56.5, TRUE, 'LC duplex', 2022,
 '{SFP56}', NULL, 'emerging',
 '100G im kleinen SFP-Gehäuse — noch höhere Dichte als SFP56. Für zukünftige High-Density-100G-Deployments wo möglichst viele Ports auf kleinem Raum benötigt werden. Noch in früher Markteinführungsphase. // 100G in the small SFP housing — even higher density than SFP56. For future high-density 100G deployments where maximum port count matters. Still in early market adoption.',
 'PAM4, 112Gbps per lane. Next evolution after SFP56. Target for 2024+ deployments.',
 'https://www.snia.org/technology-communities/sff'),

('SFP56-DD',
 'Small Form-factor Pluggable 56 Double Density (100G)',
 'SFP family', 'double density variant',
 100, 2, 53.125, 13.4, 56.5, TRUE, 'LC duplex', 2021,
 '{SFP28}', NULL, 'current',
 'Doppelte Dichte: Zwei 50G-Kanäle im SFP-Gehäuse = 100G total. Die Elektroanschlüsse sind breiter als SFP56 (8 statt 4 Pins). Für hohe 100G-Portdichte ohne QSFP-Module. // Double density: two 50G lanes in SFP housing = 100G total. Wider electrical connector than SFP56 (8 vs 4 pins). For high 100G port density without needing QSFP modules.',
 '2x25G electrical interface. Backward slot-compatible with SFP56 in many switches.',
 'https://www.snia.org/technology-communities/sff'),

-- ─────────────────────────────
-- XFP (legacy)
-- ─────────────────────────────
('XFP',
 '10 Gigabit Small Form Factor Pluggable',
 'legacy', 'XFP generation',
 10, 1, 10.3125, 18.8, 65.0, TRUE, 'LC duplex', 2002,
 '{}', 'SFP+', 'legacy',
 'Älteres 10G-Modul, deutlich größer als SFP+. War der erste weit verbreitete 10G-Standard, wurde aber vollständig durch SFP+ ersetzt da SFP+ kleiner, günstiger und effizienter ist. Noch in sehr alten Switches zu finden. // Older 10G module, significantly larger than SFP+. Was the first widely deployed 10G standard but completely replaced by SFP+, which is smaller, cheaper, and more efficient. Still found in very old switches.',
 'XFP MSA. 300-pin interface. Largely obsolete since ~2012.',
 'https://www.xfpmsa.org'),

-- ─────────────────────────────
-- QSFP Family
-- ─────────────────────────────
('QSFP+',
 'Quad Small Form-factor Pluggable Plus (40G)',
 'QSFP family', '1st generation QSFP',
 40, 4, 10.3125, 18.4, 72.4, TRUE, 'MPO-12 or LC duplex', 2010,
 '{}', 'QSFP28', 'legacy',
 '4 Kanäle à 10G = 40G total. Deutlich kompakter als 4 einzelne SFP+-Module — ein QSFP+-Port im Switch entspricht 4 SFP+-Ports. War der 40G-Standard der Rechenzentren, heute durch 100G abgelöst. // 4 channels × 10G = 40G total. Much more compact than 4 individual SFP+ modules — one QSFP+ port equals 4 SFP+ ports. Was the 40G data center standard, now largely replaced by 100G.',
 'IEEE 802.3ba. MPO-12 for SR4, LC duplex for LR4. Compatible with QSFP28 slots in many switches.',
 'https://www.snia.org/technology-communities/sff'),

('QSFP28',
 'Quad Small Form-factor Pluggable 28 (100G)',
 'QSFP family', '2nd generation QSFP',
 100, 4, 25.78125, 18.4, 72.4, TRUE, 'varies (MPO-12 or LC duplex)', 2015,
 '{QSFP+}', 'QSFP56', 'current',
 'Der 100G-Standard. 4 Kanäle à 25G = 100G total. Seit 2016 der dominante Transceiver-Typ in modernen Rechenzentren — die große Mehrheit aller 100G-Verbindungen verwendet QSFP28. Läuft oft auch in QSFP-DD-Slots. // The 100G standard. 4 channels × 25G = 100G total. The dominant transceiver type in modern data centers since 2016 — the vast majority of 100G connections use QSFP28. Often also runs in QSFP-DD slots.',
 'IEEE 802.3bm. Mechanically compatible with QSFP+. The most widely deployed 100G form factor.',
 'https://www.snia.org/technology-communities/sff'),

('QSFP56',
 'Quad Small Form-factor Pluggable 56 (200G)',
 'QSFP family', '3rd generation QSFP',
 200, 4, 53.125, 18.4, 72.4, TRUE, 'varies (MPO or LC)', 2018,
 '{QSFP28}', 'QSFP-DD', 'current',
 '4 Kanäle à 50G = 200G total (PAM4-Signal). Doppelte Kapazität von QSFP28 im selben Gehäuse. Für Netzwerke die von 100G auf 200G wechseln ohne neue Switch-Hardware zu kaufen. // 4 channels × 50G = 200G total (PAM4 signaling). Double the capacity of QSFP28 in the same housing. For networks upgrading from 100G to 200G without buying new switch hardware.',
 'IEEE 802.3cd. PAM4 modulation. Mechanically compatible with QSFP28/QSFP+ slots.',
 'https://www.snia.org/technology-communities/sff'),

('QSFP112',
 'Quad Small Form-factor Pluggable 112 (400G)',
 'QSFP family', '4th generation QSFP',
 400, 4, 112.0, 18.4, 72.4, TRUE, 'varies', 2021,
 '{QSFP56}', NULL, 'current',
 '4 Kanäle à 100G = 400G total (PAM4). Gleiche Gehäusegröße wie QSFP28 aber 4x die Kapazität. Für Rechenzentren die 400G bei maximaler Port-Dichte benötigen. // 4 channels × 100G = 400G total (PAM4). Same housing as QSFP28 but 4× the capacity. For data centers needing 400G at maximum port density.',
 'IEEE 802.3bs subset. PAM4. High thermal demands within standard QSFP envelope.',
 'https://www.snia.org/technology-communities/sff'),

('QSFP-DD',
 'Quad Small Form-factor Pluggable Double Density (400G/800G)',
 'QSFP family', 'double density QSFP',
 400, 8, 53.125, 18.4, 89.4, TRUE, 'varies (MPO-12/16 or LC)', 2019,
 '{QSFP28,QSFP56}', 'QSFP-DD800', 'current',
 'Doppelte Dichte: 8 Kanäle statt 4, für 400G (8×50G) oder mit neueren Chips 800G (8×100G). Rückwärtskompatibel — QSFP-DD-Slots können auch QSFP28-Module aufnehmen. Der wichtigste Hochgeschwindigkeitsstandard aktuell. // Double density: 8 channels instead of 4, enabling 400G (8×50G) or with newer chips 800G (8×100G). Backward compatible — QSFP-DD slots also accept QSFP28 modules. Currently the most important high-speed form factor.',
 'QSFP-DD MSA. Backward compatible with QSFP28/QSFP56. Dominant 400G standard alongside OSFP.',
 'https://www.qsfp-dd.com'),

('QSFP-DD800',
 'Quad Small Form-factor Pluggable Double Density 800 (800G)',
 'QSFP family', 'double density 800G',
 800, 8, 112.0, 18.4, 89.4, TRUE, 'varies', 2022,
 '{QSFP-DD}', NULL, 'current',
 'Die 800G-Version des QSFP-DD. 8 Kanäle à 100G = 800G total (PAM4). Für AI/ML-Cluster der neuesten Generation und Hyperscale-Netzwerke die 800G-Verbindungen benötigen. // The 800G version of QSFP-DD. 8 channels × 100G = 800G total (PAM4). For latest-generation AI/ML clusters and hyperscale networks requiring 800G connections.',
 'QSFP-DD MSA v5.0+. 8×112Gbps PAM4. Higher power envelope than standard QSFP-DD.',
 'https://www.qsfp-dd.com'),

-- ─────────────────────────────
-- OSFP Family
-- ─────────────────────────────
('OSFP',
 'Octal Small Form-factor Pluggable (400G/800G)',
 'OSFP family', '1st generation OSFP',
 800, 8, 112.0, 22.58, 100.4, TRUE, 'varies (MPO or LC)', 2019,
 '{}', 'OSFP112', 'current',
 'Etwas größer als QSFP-DD, dafür besser gekühlt. 8 Kanäle für 400G (8×50G) oder 800G (8×100G). Bevorzugt von Cisco und einigen anderen Herstellern. Bietet mehr thermischen Spielraum für leistungsstarke Kohärenz-Module. // Slightly larger than QSFP-DD but better cooled. 8 channels for 400G (8×50G) or 800G (8×100G). Preferred by Cisco and some other vendors. Provides more thermal headroom for high-power coherent modules.',
 'OSFP MSA. 22.58mm wide vs 18.4mm for QSFP-DD. Better thermal management for coherent optics.',
 'https://osfpmsa.org'),

('OSFP112',
 'Octal Small Form-factor Pluggable 112 (800G/1.6T)',
 'OSFP family', '2nd generation OSFP',
 1600, 8, 224.0, 22.58, 107.8, TRUE, 'MPO-16 or varies', 2023,
 '{OSFP}', 'OSFP224', 'emerging',
 'Nächste Generation OSFP für 800G (8×100G) und zukünftige 1.6T-Anwendungen (8×200G). Für AI/ML-Cluster der übernächsten Generation. Noch in früher Markteinführungsphase. // Next-generation OSFP for 800G (8×100G) and future 1.6T applications (8×200G). For the next-next-generation of AI/ML clusters. Still in early market adoption.',
 'OSFP MSA v2.0+. 224Gbps per lane target. Key form factor for 1.6T AI/ML networks.',
 'https://osfpmsa.org'),

('OSFP224',
 'Octal Small Form-factor Pluggable 224 (1.6T)',
 'OSFP family', '3rd generation OSFP (emerging)',
 1600, 8, 224.0, 22.58, 107.8, TRUE, 'MPO-32 or varies', 2024,
 '{OSFP112}', NULL, 'emerging',
 'Der kommende Standard für 1.6 Terabit/s: 8 Kanäle à 200G = 1.6T total. Für zukünftige AI/ML-GPU-Cluster-Verbindungen (z.B. NVIDIA NVLink 5.0 Skala). Markteinführung ab 2025/2026 erwartet. // The upcoming 1.6T standard: 8 channels × 200G = 1.6T total. For future AI/ML GPU cluster connections (e.g. NVIDIA scale-out AI networks). Market entry expected 2025/2026.',
 'OSFP MSA target. 224Gbps PAM4 per lane. Primary target for next-gen AI networking.',
 'https://osfpmsa.org'),

-- ─────────────────────────────
-- CFP Family (coherent / 100G legacy)
-- ─────────────────────────────
('CFP',
 'C Form-factor Pluggable (100G, large)',
 'CFP family', '1st generation CFP',
 100, 10, 10.3125, 82.0, 144.75, TRUE, 'LC duplex or MPO', 2010,
 '{}', 'CFP2', 'legacy',
 'Das erste 100G-Modulformat — groß wie ein Taschenbuch, für early-100G-WDM-Anwendungen. Heute veraltet und durch kleinere CFP2/CFP4 oder QSFP28 ersetzt. Noch in älteren Telko- und Transport-Geräten zu finden. // The first 100G module format — about the size of a small book, used for early 100G WDM applications. Now obsolete, replaced by smaller CFP2/CFP4 or QSFP28. Still found in older telecom and transport equipment.',
 'CFP MSA. 82mm wide. Largely obsolete since ~2014. Very high power consumption.',
 'https://www.cfp-msa.org'),

('CFP2',
 'C Form-factor Pluggable 2 (100G/200G, medium)',
 'CFP family', '2nd generation CFP',
 200, 4, 25.78125, 41.5, 107.0, TRUE, 'LC duplex or MPO', 2013,
 '{CFP}', 'CFP4', 'current',
 'Halb so groß wie CFP, doppelte Portdichte. Für 100G und 200G kohärente WDM-Anwendungen in Telekommunikationsnetzen. Weit verbreitet für langreichweitige koherente Verbindungen. // Half the size of CFP, double the port density. Used for 100G and 200G coherent WDM applications in telecom networks. Widely used for long-haul coherent links.',
 'CFP2 MSA. 41.5mm wide. Dominant coherent form factor for carrier transport equipment.',
 'https://www.cfp-msa.org'),

('CFP4',
 'C Form-factor Pluggable 4 (100G, small)',
 'CFP family', '4th generation CFP',
 100, 4, 25.78125, 21.5, 107.0, TRUE, 'LC duplex', 2014,
 '{CFP2}', NULL, 'current',
 'Ein Viertel der Größe des Original-CFP. Gleiche Portdichte wie QSFP28, aber bevorzugt für kohärente/abstimmbare WDM-Anwendungen die mehr Platz für optische Komponenten benötigen. // Quarter the size of original CFP. Same port density as QSFP28 but preferred for coherent/tunable WDM applications requiring more space for optical components.',
 'CFP4 MSA. 21.5mm wide. Popular for tunable DWDM 100G.',
 'https://www.cfp-msa.org'),

-- ─────────────────────────────
-- CXP (obsolete)
-- ─────────────────────────────
('CXP',
 'C Form-factor 10×10G (100G, parallel, legacy)',
 'legacy', 'CXP generation',
 100, 12, 10.3125, 45.0, 101.0, TRUE, 'MPO-24', 2010,
 '{}', 'QSFP28', 'obsolete',
 'Frühes 100G-Modul mit 10 parallelen 10G-Kanälen (24-Faser-MPO). Sehr kurze Produktionsphase — wurde schnell durch QSFP28 abgelöst. Praktisch nicht mehr im Einsatz. // Early 100G module using 10 parallel 10G channels (24-fiber MPO). Very short production lifetime — quickly replaced by QSFP28. Practically no longer in active use.',
 'CXP MSA. 12 lanes, 10 used for data. Replaced by QSFP28 before becoming mainstream.',
 NULL)

ON CONFLICT (name) DO UPDATE SET
  description        = EXCLUDED.description,
  full_name          = EXCLUDED.full_name,
  max_speed_gbps     = EXCLUDED.max_speed_gbps,
  status             = EXCLUDED.status,
  notes              = COALESCE(EXCLUDED.notes, form_factors.notes);
