- 030_listings_alter_yandex.sql: 7 cols (yandex_offer_id, views_total_yandex, publish_date_relative, sale_type_text, agency_name/founded_year/objects_count) + 2 partial indexes (yandex_offer_id, agency_name) - 031_houses_alter_yandex.sql: 9 cols (yandex_jk_id/slug, commission_year/month, total_area_ha, corpus_count, yandex_validated_at, yandex_total_listings, has_panorama) + 2 partial indexes (yandex_jk_id, commission_year) - 032_yandex_history.sql: enables source='yandex_valuation' on existing house_placement_history + 2 indexes (hph_source_idx, hph_house_source_idx) Foundation for YandexRealtyScraper v1 (Stages 2-9 follow on subsequent PRs). Note: numbered 030-032 because 029 was already used by PR #448 (matching/ valuation/dynamics extensions). All BEGIN/COMMIT, ADD COLUMN IF NOT EXISTS, nullable, idempotent.
41 lines
2 KiB
PL/PgSQL
41 lines
2 KiB
PL/PgSQL
-- 031_houses_alter_yandex.sql
|
|
-- Purpose: Add Yandex Realty-specific columns to houses table (ЖК landing + valuation enrichment).
|
|
-- Dependencies:
|
|
-- - houses table: 009_houses.sql
|
|
-- - 020_houses_alter_cian.sql (prior Cian columns must exist; no FK dependency, column-level only)
|
|
-- Deploy order: Apply after 030_listings_alter_yandex.sql
|
|
--
|
|
-- Sources:
|
|
-- - decisions/Schema_YandexRealty_Recon.md sec 11.2 (Newbuilding ЖК landing fields)
|
|
-- - decisions/Schema_YandexRealty_Recon.md sec 13.1 (Yandex Valuation tool enrichment)
|
|
-- - YandexRealtyScraper_v1_Implementation_Plan Stage 1
|
|
--
|
|
-- Idempotent: all ALTER TABLE uses ADD COLUMN IF NOT EXISTS; all CREATE INDEX use IF NOT EXISTS.
|
|
|
|
BEGIN;
|
|
|
|
ALTER TABLE houses
|
|
-- Yandex Newbuilding (ЖК) landing
|
|
ADD COLUMN IF NOT EXISTS yandex_jk_id text, -- '1592987'
|
|
ADD COLUMN IF NOT EXISTS yandex_jk_slug text, -- 'tatlin'
|
|
ADD COLUMN IF NOT EXISTS commission_year int, -- 2023
|
|
ADD COLUMN IF NOT EXISTS commission_month text, -- 'июнь' (raw RU month)
|
|
ADD COLUMN IF NOT EXISTS total_area_ha numeric(6,2), -- 1.50
|
|
ADD COLUMN IF NOT EXISTS corpus_count int, -- 3 (parsed from "три башни")
|
|
|
|
-- Yandex Valuation tool enrichment
|
|
ADD COLUMN IF NOT EXISTS yandex_validated_at timestamptz, -- last enrichment timestamp
|
|
ADD COLUMN IF NOT EXISTS yandex_total_listings int, -- "N объектов" в истории дома
|
|
ADD COLUMN IF NOT EXISTS has_panorama boolean; -- Yandex Panorama 3D view available
|
|
|
|
-- Partial index on yandex_jk_id for fast lookup by Yandex newbuilding identifier
|
|
CREATE INDEX IF NOT EXISTS houses_yandex_jk_idx
|
|
ON houses (yandex_jk_id)
|
|
WHERE yandex_jk_id IS NOT NULL;
|
|
|
|
-- Partial index on commission_year for filtering by year of commissioning
|
|
CREATE INDEX IF NOT EXISTS houses_commission_year_idx
|
|
ON houses (commission_year)
|
|
WHERE commission_year IS NOT NULL;
|
|
|
|
COMMIT;
|