fleet-platform/db/migrations/20260601000010_geocoded_positions.sql
kianiadee 45974b3810
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
Geocoder: cron job + state.geocoded_positions; label uses device_name last 4 (fallback plate); popup address row
2026-05-23 23:06:25 +03:00

18 lines
637 B
SQL

-- migrate:up
-- Cache layer for reverse geocoding. Keyed by lat/lng rounded to 4 decimals
-- (~10m grid), so parked vehicles share a row and only moving vehicles trigger
-- fresh lookups. Filled asynchronously by the geocoder cron job (PRD F2.3).
CREATE TABLE state.geocoded_positions (
lat_rounded numeric(8,4) NOT NULL,
lng_rounded numeric(8,4) NOT NULL,
address text,
address_short text,
source text NOT NULL DEFAULT 'nominatim',
fetched_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (lat_rounded, lng_rounded)
);
-- migrate:down
DROP TABLE IF EXISTS state.geocoded_positions;