Add FMCSA motor carrier census table and Socrata data downloader
New vertical: FMCSA/DOT motor carrier compliance services. - Migration 078: fmcsa_carriers table with 31 fields (DOT#, name, email, phone, address, fleet size, MCS-150 date, carrier type) - Downloader: Socrata API ingest for 2M+ carriers with upsert - Data source: data.transportation.gov (free, public) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
27a1a1f7ed
commit
dfee4fc6c0
2 changed files with 291 additions and 0 deletions
57
api/migrations/078_fmcsa_carriers.sql
Normal file
57
api/migrations/078_fmcsa_carriers.sql
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
-- FMCSA Motor Carrier Census Data
|
||||
CREATE TABLE IF NOT EXISTS fmcsa_carriers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
dot_number TEXT NOT NULL UNIQUE,
|
||||
legal_name TEXT NOT NULL,
|
||||
dba_name TEXT,
|
||||
carrier_operation TEXT, -- C=carrier, B=broker, etc.
|
||||
authorized_for_hire BOOLEAN DEFAULT FALSE,
|
||||
private_property BOOLEAN DEFAULT FALSE,
|
||||
private_passenger_business BOOLEAN DEFAULT FALSE,
|
||||
exempt_for_hire BOOLEAN DEFAULT FALSE,
|
||||
hm_flag BOOLEAN DEFAULT FALSE,
|
||||
|
||||
-- Contact
|
||||
email_address TEXT,
|
||||
telephone TEXT,
|
||||
|
||||
-- Physical address
|
||||
phy_street TEXT,
|
||||
phy_city TEXT,
|
||||
phy_state TEXT,
|
||||
phy_zip TEXT,
|
||||
phy_country TEXT,
|
||||
|
||||
-- Mailing address
|
||||
mailing_street TEXT,
|
||||
mailing_city TEXT,
|
||||
mailing_state TEXT,
|
||||
mailing_zip TEXT,
|
||||
mailing_country TEXT,
|
||||
|
||||
-- Fleet info
|
||||
nbr_power_unit INTEGER,
|
||||
driver_total INTEGER,
|
||||
mcs150_mileage INTEGER,
|
||||
mcs150_mileage_year INTEGER,
|
||||
recent_mileage INTEGER,
|
||||
recent_mileage_year INTEGER,
|
||||
|
||||
-- Compliance dates
|
||||
mcs150_date TEXT, -- raw date string from FMCSA
|
||||
mcs150_parsed DATE, -- parsed for querying
|
||||
add_date TEXT, -- registration date
|
||||
|
||||
-- State info
|
||||
oic_state TEXT, -- state of principal office
|
||||
|
||||
-- Metadata
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_fmcsa_dot ON fmcsa_carriers(dot_number);
|
||||
CREATE INDEX IF NOT EXISTS idx_fmcsa_email ON fmcsa_carriers(email_address) WHERE email_address IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_fmcsa_state ON fmcsa_carriers(phy_state);
|
||||
CREATE INDEX IF NOT EXISTS idx_fmcsa_mcs150 ON fmcsa_carriers(mcs150_parsed);
|
||||
CREATE INDEX IF NOT EXISTS idx_fmcsa_hire ON fmcsa_carriers(authorized_for_hire) WHERE authorized_for_hire = TRUE;
|
||||
Loading…
Add table
Add a link
Reference in a new issue