fix(tradein): plain natural-key dedup_hash for rosreestr deals (#576) #638
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#638
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/576-dedup-hash-plain-key"
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
Closes #576. rosreestr ДКП deals used
dedup_hash = md5('ros:dkp:' || id)— a hash of an already-unique natural key: collision-prone (theoretically), not human-readable, and irreversible (couldn't recover the source id, which mattered becausedeals.source_idwas never populated).Replace with the plain natural key
'ros:dkp:' || id(injective, zero-collision, reversible) and populatedeals.source_idgoing forward — in both the live scheduler import (import_rosreestr_dkp) and the legacydeploy/import-rosreestr.sh.Migration 077 backfills the existing 49,791 rows: recovers the original id from FDW foreign table
gendesign_rosreestr_dealsby matching the old md5, then writes plain key + source_id. Idempotent; plain keys and md5 hex are format-disjoint → no transient UNIQUE violation ondeals_dedup_hash_key. Runs exactly-once under the new_schema_migrationsgate (PR #637).Reviewed by code-reviewer: ✅ approve, no blockers (full cross-file impact check — nothing reads
deals.dedup_hashas md5 ordeals.source_id; estimator_fetch_dealsfilters by geo/rooms/area/date only, unaffected).Test plan
bash -ncleanUPDATE 49791→md5_after=0, plain_after=49791, source_id_filled=49791, 3.85s with FDW joinSELECT count(*) FROM deals WHERE source='rosreestr' AND dedup_hash ~ '^[0-9a-f]{32}$'= 0; next rosreestr_dkp_import inserts plain-keyed without dupesCloses #576
rosreestr ДКП deals used dedup_hash = md5('ros:dkp:' || id) — a hash of an already-unique natural key. The md5 is collision-prone (theoretically), not human-readable, and irreversible (can't recover the source id from it, which mattered because deals.source_id was never populated). Replace with the plain natural key 'ros:dkp:' || id (injective, zero collision, reversible) and populate deals.source_id going forward, in both the live scheduler import (import_rosreestr_dkp) and the legacy deploy/import-rosreestr.sh. Migration 077 backfills the existing 49,791 rows: recovers the original id from FDW foreign table gendesign_rosreestr_deals by matching the old md5, then writes the plain key + source_id. Idempotent; plain keys and md5 hex are format-disjoint so no transient UNIQUE violation on deals_dedup_hash_key. Verified via prod dry-run (ROLLBACK): UPDATE 49791, 0 md5 remaining, 3.85s. Closes #576