new-site/api/migrations/080_carrier_operating_states.sql
justin 33da00fd89 50-state trucking compliance: services, checker, order page, CA landing
- Migration 079: state_trucking_requirements table seeded for all 51 jurisdictions
  (IRP, IFTA, weight-distance taxes, MCP/CARB, intrastate authority, state DOT)
- Migration 080: carrier_operating_states tracking table
- 13 new state trucking services in catalog ($99-$599)
- StateTruckingHandler with state-specific admin todos
- DOT compliance checker: 7 new state-level checks (IRP, IFTA, weight tax,
  MCP/CARB, emissions, intrastate authority, state DOT number)
- New API endpoint: GET /api/v1/dot/state-requirements
- DOT order page: state compliance service cards with auto-preselect
- California trucking landing page (MCP + CARB + IRP + IFTA)
- Fix: DOT checker nav missing Trucking/DOT section
- Fix: All 8 DOT intake pages missing style block (dangling text)
- Fix: DOT confirmation email now says "Order Confirmed" not "Action Required"
- Fix: MCS150/BOC3/StateTrucking handlers missing async process() method
- Fix: StateTruckingHandler connection leak + slug resolution

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-29 12:46:33 -05:00

27 lines
1.1 KiB
PL/PgSQL

-- 080_carrier_operating_states.sql
--
-- Track which states a carrier operates in. Populated from:
-- - Intake forms (customer self-reports operating states)
-- - FMCSA census (phy_state as base state)
-- - Inferred from order history
--
-- Used by the DOT compliance checker to show state-specific requirements
-- and by the deficiency flagger for state-targeted campaigns.
BEGIN;
CREATE TABLE IF NOT EXISTS carrier_operating_states (
id SERIAL PRIMARY KEY,
dot_number TEXT NOT NULL,
state_code CHAR(2) NOT NULL,
is_base_state BOOLEAN NOT NULL DEFAULT FALSE,
source TEXT NOT NULL DEFAULT 'intake', -- 'intake', 'census', 'inferred'
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (dot_number, state_code)
);
CREATE INDEX IF NOT EXISTS idx_carrier_ops_dot ON carrier_operating_states(dot_number);
CREATE INDEX IF NOT EXISTS idx_carrier_ops_state ON carrier_operating_states(state_code);
CREATE INDEX IF NOT EXISTS idx_carrier_ops_base ON carrier_operating_states(is_base_state) WHERE is_base_state = TRUE;
COMMIT;