Files
cannaiq/backend/migrations/091_store_discovery_tracking.sql
Kelly 55b26e9153 feat: Auto-healing entry_point_discovery with browser-first transport
- Rewrote entry_point_discovery with auto-healing scheme:
  1. Check dutchie_discovery_locations for existing platform_location_id
  2. Browser-based GraphQL with 5x network retries
  3. Mark as needs_investigation on hard failure
- Browser (Puppeteer) is now DEFAULT transport - curl only when explicit
- Added migration 091 for tracking columns:
  - last_store_discovery_at: When store_discovery updated record
  - last_payload_at: When last product payload was saved
- Updated CODEBASE_MAP.md with transport rules documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2025-12-12 22:55:21 -07:00

27 lines
1.2 KiB
SQL

-- Migration 091: Add store discovery tracking columns
-- Per auto-healing scheme (2025-12-12):
-- Track when store_discovery last updated each dispensary
-- Track when last payload was saved
-- Add last_store_discovery_at to track when store_discovery updated this record
ALTER TABLE dispensaries
ADD COLUMN IF NOT EXISTS last_store_discovery_at TIMESTAMPTZ;
-- Add last_payload_at to track when last product payload was saved
-- (Complements last_fetch_at which tracks API fetch time)
ALTER TABLE dispensaries
ADD COLUMN IF NOT EXISTS last_payload_at TIMESTAMPTZ;
-- Add index for finding stale discovery data
CREATE INDEX IF NOT EXISTS idx_dispensaries_store_discovery_at
ON dispensaries (last_store_discovery_at DESC NULLS LAST)
WHERE crawl_enabled = true;
-- Add index for finding dispensaries without recent payloads
CREATE INDEX IF NOT EXISTS idx_dispensaries_payload_at
ON dispensaries (last_payload_at DESC NULLS LAST)
WHERE crawl_enabled = true;
COMMENT ON COLUMN dispensaries.last_store_discovery_at IS 'When store_discovery task last updated this record';
COMMENT ON COLUMN dispensaries.last_payload_at IS 'When last product payload was saved for this dispensary';