refactor(tradein): unify kadastr_num → cadastral_number (#732) #891
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#891
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/732-cadastral-unify"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
p3 naming-consistency (cadastral columns are 0%-filled across tradein). Migration 094
cadastral_unify.sql(idempotent,DO-blockIF EXISTSguards):listings_search_mv(MV) +v_data_quality(view) with the renamed column;deals.kadastr_num+house_metadata.kadastr_num→cadastral_number;listings.kadastr_num+listings_kadastr_idx(listings.cadastral_numberalready exists, 0 rows);REFRESH MATERIALIZED VIEW.Code SQL-string renames in
search_query.py,estimator.py,base.pyINSERT (theLot.kadastr_numdataclass field is intentionally NOT renamed — out of scope, would break scraper→DB mapping).Test plan
pytest -k "estimator or search or save_listings or base"→ 240 passed (1 pre-existing env failure, unrelated); ruff clean./estimate200,SELECT 1 FROM v_data_quality/listings_search_mvok,information_schema.columnshas nokadastr_num.⚠️ MERGE-GATE — destructive DDL, do NOT auto-merge
This migration auto-applies to prod on deploy and is destructive: drops the search MV + data-quality view + a column, renames columns (irreversible without backup). Hold merge until post-demo (2026-06-01) and:
pg_get_viewdef/pg_matviewsdefinitions before applying — the worker reconstructed them from migration history (050/046), not a live capture, so any later drift would make the recreate wrong.pg_dump -t deals -t house_metadata -t listingssnapshot first; the finalREFRESH MATERIALIZED VIEWholds a lock onlistings— apply in a low-traffic window.Refs #732
🔴 HOLD — destructive DDL merge-gate (не мержу).
Миграция 094 auto-applies на prod на деплое и деструктивна: DROP
listings.kadastr_num+ idx, DROP/recreatelistings_search_mv+v_data_quality, RENAMEdeals/house_metadata.kadastr_num— необратимо без бэкапа.Критический риск (сам автор флагнул): MV + view реконструированы из истории миграций (050/046), не из live
pg_get_viewdef/pg_matviews. Если prod-определения дрейфанули — recreate молча перезапишет search-MV / data-quality-view неправильной версией. Это обязательная human/ops pre-merge проверка против живой БД — я (headless reviewer) livepg_get_viewdefсверить не могу и DDL исполнять не должен (read-only).Плюс:
REFRESH MATERIALIZED VIEWдержит lock наlistings→ low-traffic окно +pg_dump -t deals -t house_metadata -t listingsснапшот ПЕРЕД применением. p3, post-demo (не демо-критично).Код-уровень (для будущего merge): idempotent
DO-block IF EXISTS guards разумны;Lot.kadastr_numdataclass намеренно не тронут (scraper→DB mapping) — корректное решение; SQL-string ренеймы в search_query/estimator/base. Но мерж деструктивной DDL за день до демо без live-DDL-сверки и бэкапа = человеческий/ops acт.→
+needs-human +blocked. Ops: сверить recreate-DDL с livepg_get_viewdef, снятьpg_dump, применить post-demo в low-traffic окно.