feat(db): bulk cadastre schema — 7 tables + cadastre_jobs (#168 PR1/5) #169

Merged
lekss361 merged 2 commits from feat/cadastre-bulk-schema into main 2026-05-15 10:05:26 +00:00

2 commits

Author SHA1 Message Date
lekss361
b4bc70489b fixup(db): address PR #169 bot review — 2 blockers + 3 lessers
Blocker #1: cad_parcels_geom DROP → back-compat VIEW
  Old DROP TABLE would break site-finder analyze fallback (per 83_*.sql COMMENT).
  Now: drop old BASE TABLE (guarded by table_type), create VIEW over cad_parcels
  with identical 4-column signature. Callers continue to work; PR2/5 will switch.

Blocker #2: K.3 redundant RENAME CONSTRAINT removed
  ALTER INDEX RENAME on PK index already renames the backing constraint in PG16.
  Second ALTER TABLE RENAME CONSTRAINT would throw 'does not exist' and abort tx.

Lesser #1: cadastre_jobs.status CHECK constraint
  Inline CHECK (status IN ('queued','running','done','failed','zombie','cancelled','paused'))
  per partial-index intent and admin UI plan.

Lesser #2: COMMENT ON TABLE for all 8 tables + view (keeps convention from 63, 83).

Lesser #3: set_updated_at() triggers on 7 tables with updated_at column.
  Reuses existing function (verified present). DO $$ guards on pg_trigger
  for idempotent re-apply. cadastre_jobs excluded (uses heartbeat_at instead).
2026-05-15 12:59:42 +03:00
lekss361
c6fb30fdea feat(db): schema migration for bulk cadastre ingest layers (#168)
Add 7 cadastre layer tables + cadastre_jobs saga-state table.

Tables:
- cad_parcels (36368 ЗУ ЕГРН) replaces cad_parcels_geom
- cad_buildings v2 wide schema (replaces existing, backed up as cad_buildings_old_apr26)
- cad_constructions (36383 Сооружения + ЕГРН, flag is_egrn)
- cad_oncs (36384), cad_enk (39663), cad_zouit (4 categoryIds), cad_quarter_stats
- cadastre_jobs (resumable saga state, mirrors geo_jobs pattern)

GIST + BTREE indexes. Migration of cad_parcels_geom data via INSERT...SELECT.
Restore v_complex_full + v_complex_buildings views after table rename.
2026-05-15 12:33:08 +03:00