Files
cannaiq/backend/migrations/044_add_provider_detection_data.sql
Kelly b4a2fb7d03 feat: Add v2 architecture with multi-state support and orchestrator services
Major additions:
- Multi-state expansion: states table, StateSelector, NationalDashboard, StateHeatmap, CrossStateCompare
- Orchestrator services: trace service, error taxonomy, retry manager, proxy rotator
- Discovery system: dutchie discovery service, geo validation, city seeding scripts
- Analytics infrastructure: analytics v2 routes, brand/pricing/stores intelligence pages
- Local development: setup-local.sh starts all 5 services (postgres, backend, cannaiq, findadispo, findagram)
- Migrations 037-056: crawler profiles, states, analytics indexes, worker metadata

Frontend pages added:
- Discovery, ChainsDashboard, IntelligenceBrands, IntelligencePricing, IntelligenceStores
- StateHeatmap, CrossStateCompare, SyncInfoPanel

Components added:
- StateSelector, OrchestratorTraceModal, WorkflowStepper

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 11:30:57 -07:00

46 lines
1.7 KiB
PL/PgSQL

-- Migration 044: Add provider_detection_data column to dispensaries
--
-- This column stores detection metadata for menu provider discovery.
-- Used by menu-detection.ts and discovery.ts to track:
-- - Detected provider type
-- - Resolution attempts
-- - Error messages
-- - not_crawlable flag
--
-- Run with: psql $CANNAIQ_DB_URL -f migrations/044_add_provider_detection_data.sql
--
-- ALL CHANGES ARE ADDITIVE - NO DROPS, NO DELETES, NO TRUNCATES.
-- Add provider_detection_data to dispensaries table
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'dispensaries' AND column_name = 'provider_detection_data'
) THEN
ALTER TABLE dispensaries
ADD COLUMN provider_detection_data JSONB DEFAULT NULL;
RAISE NOTICE 'Added provider_detection_data column to dispensaries table';
ELSE
RAISE NOTICE 'provider_detection_data column already exists on dispensaries table';
END IF;
END;
$$ LANGUAGE plpgsql;
-- Add index for querying by not_crawlable flag
CREATE INDEX IF NOT EXISTS idx_dispensaries_provider_detection_not_crawlable
ON dispensaries ((provider_detection_data->>'not_crawlable'))
WHERE provider_detection_data IS NOT NULL;
-- Add index for querying by detected provider
CREATE INDEX IF NOT EXISTS idx_dispensaries_provider_detection_provider
ON dispensaries ((provider_detection_data->>'detected_provider'))
WHERE provider_detection_data IS NOT NULL;
COMMENT ON COLUMN dispensaries.provider_detection_data IS 'JSONB metadata from menu provider detection. Keys: detected_provider, resolution_error, not_crawlable, detection_timestamp';
-- =====================================================
-- MIGRATION COMPLETE
-- =====================================================