-- Migration 038: Add data-quality columns to stock_observations + selective cleanup -- -- stock_confidence: 1 = boolean only (in_stock true/false) -- 2 = aggregated global count (single number, e.g. QSFPTEK) -- 3 = per-warehouse breakdown (e.g. FS.com DE/Global split) -- price_currency: ISO 4217 code, e.g. 'USD', 'EUR', 'GBP' -- price_includes_tax: true = gross price, false = net/excl. VAT -- stock_vendor_ts: timestamp as reported by vendor (e.g. QSFPTEK "17 Apr 2026") ALTER TABLE stock_observations ADD COLUMN IF NOT EXISTS stock_confidence SMALLINT DEFAULT 1 CHECK (stock_confidence IN (1, 2, 3)), ADD COLUMN IF NOT EXISTS price_currency CHAR(3), ADD COLUMN IF NOT EXISTS price_includes_tax BOOLEAN, ADD COLUMN IF NOT EXISTS stock_vendor_ts TIMESTAMPTZ; -- ── Selective cleanup ─────────────────────────────────────────────────────── -- Truncate stock_observations: all 186 rows are from the first FS.com test run. -- They will be repopulated automatically at the next scheduled scraper run -- (02:00 / 10:00 / 18:00 via launchd). Transceiver catalog, specs, vendors, -- price_observations, and all other tables are left untouched. TRUNCATE TABLE stock_observations;