# Platform Vehicle Data Loader Refresh ## Context - Reintroduced the normalized `vehicles` schema (make/model/model_year/trim/engine + bridges) with a new migration under `backend/src/features/platform/migrations/001_create_vehicle_lookup_schema.sql`. - Added `scripts/load_vehicle_data.py`, a stand-alone Python loader that hydrates the schema from `data/make-models/*.json`. - Loader truncates lookup tables, seeds default transmissions (Automatic, Manual), and inserts deduplicated year → make → model → trim → engine combinations. ## Follow-up Tasks (Backend API Team) 1. **Wire dropdown API to refreshed data** - Run `make migrate` (or `npm run migrate:all` inside backend container) to ensure the new schema exists. - Execute the loader (see command below) so Postgres has the latest lookup entries. - Verify both the platform dropdown queries and the admin catalog APIs surface the same data set (admin APIs now read directly from `vehicles.*` tables). 2. **Add Makefile wrapper** - Create a `make load-vehicle-data` task that shells into the backend container, installs `psycopg` if needed, and invokes `python3 scripts/load_vehicle_data.py` with the correct DB credentials and data directory. ### Loader Command Reference ``` PGPASSWORD=$(cat secrets/app/postgres-password.txt) \ python3 scripts/load_vehicle_data.py \ --db-host 127.0.0.1 \ --db-port 5432 \ --db-user postgres \ --db-name motovaultpro \ --data-dir data/make-models ``` > Run the command from the repository root (outside of containers) while `mvp-postgres` is up. Adjust host/port if executing inside a container. ## 2025-11-07 Update - Admin catalog CRUD endpoints have been refactored to read/write the normalized `vehicles.*` tables instead of the legacy `vehicle_dropdown_cache`. - Platform cache invalidation now happens immediately after each catalog mutation so both the admin UI and the user dropdown APIs stay in sync.