Files
cannaiq/backend/migrations/043_add_states_table.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

51 lines
1.5 KiB
SQL

-- Migration 043: Add States Table
--
-- Creates the states table if it does not exist.
-- Safe to run multiple times (idempotent).
--
-- Run with:
-- CANNAIQ_DB_URL="postgresql://..." psql $CANNAIQ_DB_URL -f migrations/043_add_states_table.sql
-- =====================================================
-- 1) CREATE STATES TABLE
-- =====================================================
CREATE TABLE IF NOT EXISTS states (
id SERIAL PRIMARY KEY,
code TEXT NOT NULL UNIQUE,
name TEXT NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- =====================================================
-- 2) INSERT CORE US STATES
-- =====================================================
INSERT INTO states (code, name) VALUES
('AZ', 'Arizona'),
('CA', 'California'),
('CO', 'Colorado'),
('FL', 'Florida'),
('IL', 'Illinois'),
('MA', 'Massachusetts'),
('MD', 'Maryland'),
('MI', 'Michigan'),
('MO', 'Missouri'),
('NV', 'Nevada'),
('NJ', 'New Jersey'),
('NY', 'New York'),
('OH', 'Ohio'),
('OK', 'Oklahoma'),
('OR', 'Oregon'),
('PA', 'Pennsylvania'),
('WA', 'Washington')
ON CONFLICT (code) DO NOTHING;
-- =====================================================
-- 3) ADD INDEX
-- =====================================================
CREATE INDEX IF NOT EXISTS idx_states_code ON states(code);
-- =====================================================
-- DONE
-- =====================================================