feat(tradein): SQL 040-046 — matching schema delta (Phase 1.1) #464
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#464
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/tradein-matching-schema"
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?
Motivation
Phase 1.1 of Multi-Source Integration. Foundation for matching module (Phase 1.2)
Gap-audit finding
Original spec proposed 7 CREATE TABLE migrations. Audit of existing SQL
(014/017/020/026/028/029/030/031) revealed 80%+ of planned schema already
in place. This PR ships thin delta only (mostly ALTER ADD COLUMN
IF NOT EXISTS + 3 views).
Files
Total: 7 files / 232 lines SQL.
Coordination
030_avito_imv_cache_key_unique+030_listings_alter_yandexboth kept as-is)IF NOT EXISTS, every indexIF NOT EXISTS, viewsOR REPLACE)Smoke verification (post-merge on prod)
Reviewer
deep-code-reviewer — please verify:
lat,kadastr_num,description,is_active,is_outlier,source,house_id_fk)Refs
decisions/MultiSource_Integration_Master_Plan.mddecisions/Cross_Source_Matching_Strategy.mdMerged via deep-code-reviewer — verdict APPROVE (squash
5e90797a).Verification done
listings.lat / kadastr_num / description / is_active / is_outlier / source / scraped_at / house_id_fkall exist (002+011);houses.year_built(009);house_sources.house_id / ext_source(028);listings WHERE source IN ('avito','cian','yandex')matches existing source valuesdata/sql/, no overlap with Pythonscrapers/UNIQUE (source, cache_key)from 026 — every row hits thisUNIQUE (source, house_id, listing_id) WHERE house_id IS NOT NULL AND listing_id IS NOT NULL— partial, IMV cache rows with NULL canonical refs bypass it cleanlyIdempotency — every file wrapped
BEGIN; ... COMMIT;, every DDL guarded (IF NOT EXISTS/CREATE OR REPLACE). Re-apply safe.Cross-file impact
ON DELETE CASCADEonexternal_valuations.house_id / listing_id— acceptable (cache rows become orphan anyway if parent deleted)045 ADD COLUMN source_confidence real DEFAULT 1.0— PG ≥11 metadata-only, no full table rewriteMinor (non-blocking)
v_data_qualityis a regular view — every call re-executes 15+ subqueries. If/api/v1/admin/data-qualitypolls frequently, considerMATERIALIZED VIEW+REFRESH MATERIALIZED VIEW CONCURRENTLY(deferred — current scope OK)v_data_quality(houses 2plus_sources,3plus_sources,listings_dedup_2sources) repeat full GROUP BY; could share a CTE — deferPhase 1.1 unblocks Phase 1.2 (matching module Python), Phase 3.1 (search optimization), Phase 3.3 (estimate refactor).