-- Migration 075: Add consecutive_misses column to store_products -- Used to track how many consecutive crawls a product has been missing from the feed -- After 3 consecutive misses, product is marked as OOS ALTER TABLE store_products ADD COLUMN IF NOT EXISTS consecutive_misses INTEGER NOT NULL DEFAULT 0; -- Index for finding products that need OOS check CREATE INDEX IF NOT EXISTS idx_store_products_consecutive_misses ON store_products (dispensary_id, consecutive_misses) WHERE consecutive_misses > 0; COMMENT ON COLUMN store_products.consecutive_misses IS 'Number of consecutive crawls where product was not in feed. Reset to 0 when seen. At 3, mark OOS.';