feat(CRIT-010): add oil_prices API endpoint with zone-to-county mapping

Add GET /oil-prices/county/:county_id public endpoint to serve scraped
oil price data by county. Includes oil_prices table definition in schema
and a backfill script to populate county_id on existing records.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-09 18:31:38 -05:00
parent caa318508b
commit 85bbe43192
6 changed files with 134 additions and 1 deletions

View File

@@ -58,6 +58,22 @@ CREATE TABLE listings (
last_edited TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
);
-- Oil prices (scraped from NewEnglandOil.com / MaineOil.com)
CREATE TABLE oil_prices (
id SERIAL PRIMARY KEY,
state VARCHAR(100),
zone INTEGER,
name VARCHAR(255),
price DOUBLE PRECISION,
date VARCHAR(20),
scrapetimestamp TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
company_id INTEGER,
county_id INTEGER
);
-- If the table already exists, add county_id
-- ALTER TABLE oil_prices ADD COLUMN county_id INTEGER;
-- If the table already exists, add the new columns
-- ALTER TABLE listings ADD COLUMN price_per_gallon_cash DOUBLE PRECISION;
-- ALTER TABLE listings ADD COLUMN note TEXT;