Merge pull request 'feat(site-finder): view v_tradein_osm_poi_ekb для FDW-моста trade-in location-coef (#2045 PR-A)' (#2299) from feat/gendesign-osm-poi-tradein-view into main
All checks were successful
Deploy / changes (push) Successful in 8s
Deploy / build-frontend (push) Has been skipped
Deploy / build-backend (push) Successful in 37s
Deploy / build-worker (push) Successful in 40s
Deploy / deploy (push) Successful in 1m26s

This commit is contained in:
lekss361 2026-07-03 20:14:23 +00:00
commit 64d3a925ef

View file

@ -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;