From 404d88ee3409e5f31509d3372669617ab7951cf9 Mon Sep 17 00:00:00 2001 From: bot-backend Date: Fri, 3 Jul 2026 22:54:03 +0300 Subject: [PATCH] =?UTF-8?q?feat(site-finder):=20view=20v=5Ftradein=5Fosm?= =?UTF-8?q?=5Fpoi=5Fekb=20=D0=B4=D0=BB=D1=8F=20FDW-=D0=BC=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=20trade-in=20location-coef=20(#2045)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/sql/185_tradein_osm_poi_view.sql | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 data/sql/185_tradein_osm_poi_view.sql diff --git a/data/sql/185_tradein_osm_poi_view.sql b/data/sql/185_tradein_osm_poi_view.sql new file mode 100644 index 00000000..452ae312 --- /dev/null +++ b/data/sql/185_tradein_osm_poi_view.sql @@ -0,0 +1,32 @@ +-- 185_tradein_osm_poi_view.sql +-- Issue #2045 (trade-in location-coef/POI, PR 1 of 2 — gendesign side only). +-- Exposes osm_poi_ekb (82_osm_poi_ekb.sql) to tradein-postgres via the existing +-- postgres_fdw bridge / tradein_fdw_reader role (100_tradein_fdw_role.sql). +-- Mirrors v_tradein_cad_buildings: flat, minimal column slice + freshness filter, +-- GRANT SELECT to the already-existing role (no new role / no user mapping here). +-- +-- Second PR (FDW foreign table + service in tradein-mvp) lands separately AFTER +-- this migration is deployed on gendesign. +-- +-- Idempotent: CREATE OR REPLACE VIEW + repeatable GRANT. + +BEGIN; + +CREATE OR REPLACE VIEW v_tradein_osm_poi_ekb AS +SELECT + category, + name, + lat, + lon +FROM osm_poi_ekb +WHERE last_osm_edit_date IS NULL + OR last_osm_edit_date > now() - interval '2 years'; + +GRANT SELECT ON v_tradein_osm_poi_ekb TO tradein_fdw_reader; + +COMMENT ON VIEW v_tradein_osm_poi_ekb IS + 'FDW source for tradein-mvp (postgres_fdw) location-coef/POI scoring (#2045). ' + 'Flat 4-col EKB-only slice of osm_poi_ekb, filtered to POI edited within 2 years ' + '(or with unknown edit date).'; + +COMMIT;