- 019: ALTER listings (windows_view_type, wcs counts, ceiling_height,
repair_type, views, living_area, bedrooms, balconies, loggias,
description_minhash, cadastral_number, phones, bargain_allowed,
sale_type, house_source/ext_id, metro_stations)
- 020: ALTER houses (BTI: series_name, entrances, flat_count, is_emergency,
heat/gas/overlap types; Cian: cian_internal_house_id,
management_company_id, transport_accessibility_rate,
advantages/banks/builders/houses_by_turn jsonb + GIN indexes)
- 021: CREATE management_companies + FK to houses.management_company_id
- 022: CREATE agents table + agent_id_fk on listings
- 023: CREATE offer_price_history (per-listing price change timeline)
- 024: CREATE houses_price_dynamics (monthly price/sqm series)
- 025: CREATE house_reliability_checks (наш.дом.рф checks)
- 026: CREATE external_valuations (unified Avito IMV + Cian Valuation cache)
- 027: CREATE EXTENSION pgcrypto + cian_session_cookies (encrypted)
- 028: CREATE house_sources, listing_sources, house_address_aliases
+ address_fingerprint/canonical/merged_into alters
Refs: decisions/CianScraper_v1_Implementation_Plan.md Stage 1
decisions/Schema_Cian_SERP_Inventory.md sec 16, 20.3, 26
decisions/Cross_Source_Matching_Strategy.md sec 2
26 lines
1 KiB
PL/PgSQL
26 lines
1 KiB
PL/PgSQL
-- 024_houses_price_dynamics.sql
|
|
-- Purpose: Monthly price time-series per house (from Cian newbuilding realtyValuation.priceDynamics).
|
|
-- Stores per room_count / prices_type / period granularity as provided by Cian.
|
|
-- Dependencies:
|
|
-- - houses table (009_houses.sql)
|
|
-- Deploy order: Apply after 023.
|
|
--
|
|
-- Sources: Schema_Cian_SERP_Inventory sec 16.3
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE IF NOT EXISTS houses_price_dynamics (
|
|
id bigserial PRIMARY KEY,
|
|
house_id bigint NOT NULL REFERENCES houses(id) ON DELETE CASCADE,
|
|
month_date date NOT NULL, -- '2025-11-01' (first of month)
|
|
price_per_sqm numeric NOT NULL, -- avg price per sqm for that month
|
|
source text NOT NULL DEFAULT 'cian_realty_valuation',
|
|
recorded_at timestamptz NOT NULL DEFAULT NOW(),
|
|
UNIQUE (house_id, month_date, source)
|
|
);
|
|
|
|
-- Primary read pattern: time-ordered series for a house
|
|
CREATE INDEX IF NOT EXISTS hpd_house_date_idx
|
|
ON houses_price_dynamics (house_id, month_date DESC);
|
|
|
|
COMMIT;
|