MEGAINFRA-WEBAPP/scripts/migrations
DEIs 87f75dd98f feat(plant): fleet map page with GPS-denormalised vehicles, clustering, and tile switcher
Adds /dashboard/plant/map: a Leaflet view of every vehicle scanned from
the MEGA Clock kiosk, plotted at its last known position.

Schema
- vehicles.last_latitude / last_longitude / last_scanned_at /
  last_location_accuracy_m denormalised off fuel_logs so the map page
  renders every vehicle in a single query. Same best-effort pattern as
  attention_dismissed_at; updated by /api/clock/vehicle-scan after every
  successful scan. PB init defaults new number cols to 0 (not null) —
  filter uses 'last_latitude > 0 || last_latitude < 0' to mean 'real fix'.
- Indexed via idx_vehicles_last_scanned.

Map UI
- Custom SVG markers per unit_type: car silhouette for fuel, tractor
  silhouette for plant, 24x24, drop-shadowed.
- Clustering via react-leaflet-cluster over Leaflet.markercluster.
  Cluster icons colour-ramp with size (green->sky->amber->rose) and
  scale 32->54px.
- Three-button base-layer switcher: Street (OSM), Dark (ESRI Dark
  Gray Canvas — CartoDB watermarks tiles without a key), Satellite
  (ESRI World Imagery). Last choice persists in localStorage.
- Site pins: small purple map-marker divIcon, click flies the map to
  zoom level 15.
- Empty-state is a floating chip on the map rather than a full-page
  card so the map is always visible.

APIs
- /api/clock/vehicle-scan: stores the GPS fix on the fuel_logs row
  AND denormalises onto the vehicle when present; missing-coord
  scan leaves last_* untouched.

Sidebar: new Map entry under Plant group.
2026-09-22 21:39:25 +02:00
..
2026-08-19-extend-data-import-batches.py
2026-08-24-data-import-batches-allow-xlsx.py fix(data-import-batches): allow xlsx MIME on original_file 2026-08-24 22:17:45 +02:00
2026-08-24-fuel-logs-latest-consumption.py feat(fuel): drop-in xlsx/csv import for pump sheets 2026-08-24 22:03:08 +02:00
2026-08-28-vehicles-attention-dismissed.py feat(fuel): PB schema migration for attention_dismissed_at 2026-08-28 12:26:23 +02:00
2026-08-28-vehicles-unit-type-optional.py fix(pb): make vehicles.unit_type optional 2026-08-28 15:26:33 +02:00
2026-08-29-fixed-costs-recurring-backfill.py fix(schema): ensure is_recurring=false writes are preserved 2026-08-28 13:43:38 +02:00
2026-08-31-data-import-batches-allow-pdf-images.py fix(pb): allow PDF and image MIME on data_import_batches.original_file 2026-08-31 12:20:41 +02:00
2026-09-11-add-document-fields.py feat(schema): add file_hash and queue fields to DNs and POs 2026-09-11 10:29:10 +02:00
2026-09-11-add-site-work-month-field.py docs(project-calendar): add the project month/week plan; fix a stale doc reference 2026-09-11 22:35:41 +02:00
2026-09-11-backfill-entity-file-hashes.py fix(migration): separate download failures from missing files 2026-09-11 10:39:54 +02:00
2026-09-11-backfill-fuel-log-sites.py fix(fuel): backfill site on 147 orphaned fuel logs 2026-09-11 10:44:19 +02:00
2026-09-11-backfill-timesheet-sites.py fix(timesheets): stamp site on log rows, ending read-time drift 2026-09-11 10:48:51 +02:00
2026-09-12-add-clock-events.py feat(clock): add clock_events PocketBase collection 2026-09-12 00:14:13 +02:00
2026-09-12-add-po-date-uploaded.py fix(purchasing): restore the 30-day PO dedup window with a real timestamp 2026-09-11 14:17:42 +02:00
2026-09-12-create-document-collections.py feat(schema): add timesheets, fuel_sheets, plant_hours_sheets documents 2026-09-11 11:09:14 +02:00
2026-09-12-migrate-batches-to-documents.py feat(migration): move batch files into document collections 2026-09-11 13:06:40 +02:00
2026-09-12-rename-collections.py refactor(schema): rename received_items and timesheets to their real names 2026-09-11 11:01:40 +02:00
2026-09-12-widen-sheet-mimetypes.py feat(schema): add timesheets, fuel_sheets, plant_hours_sheets documents 2026-09-11 11:09:14 +02:00
2026-09-14-require-site.py feat(schema): require site on every ingested collection 2026-09-11 15:32:48 +02:00
2026-09-15-add-indexes.py perf(schema): index the columns every per-site query filters on 2026-09-11 16:08:34 +02:00
2026-09-15-drop-legacy-columns.py refactor(schema): drop project_code, qty_outstanding, PLANT and data_import_batches 2026-09-11 16:05:42 +02:00
2026-09-16-add-suppliers-schema.py feat(schema): add suppliers collection and purchase_orders.supplier_ref 2026-09-11 18:12:30 +02:00
2026-09-16-migrate-suppliers.py feat(suppliers): migrate existing PO supplier text onto supplier records 2026-09-11 18:14:05 +02:00
2026-09-22-add-fuel-log-coordinates.py feat(clock): enhance vehicle scan API with GPS support 2026-09-22 19:59:44 +02:00
2026-09-22-add-vehicle-last-location.py feat(plant): fleet map page with GPS-denormalised vehicles, clustering, and tile switcher 2026-09-22 21:39:25 +02:00