gendesign/tradein-mvp/backend/data/sql/010_houses_alter.sql
lekss361 a2147872ed
All checks were successful
Deploy Trade-In / build-backend (push) Successful in 23s
Deploy Trade-In / deploy (push) Successful in 27s
Deploy Trade-In / changes (push) Successful in 5s
Deploy Trade-In / build-frontend (push) Has been skipped
feat(tradein): SQL migrations 009-018 — houses + listings extension + IMV cache (#440)
2026-05-23 11:41:44 +00:00

58 lines
3.5 KiB
PL/PgSQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 010_houses_alter.sql
-- ALTER TABLE houses — добавить 15+ полей из Houses Catalog endpoint
-- (material_walls, parking_type, rating_distribution, raw_characteristics, etc.)
--
-- Dependencies: 009_houses.sql (houses table must exist)
-- Apply after: 009_houses.sql
-- Apply before: 011_listings_alter.sql
--
-- Source: decisions/Schema_Avito_Houses_Listings_History.md sec 25
--
-- Идемпотентно: ADD COLUMN IF NOT EXISTS безопасен при повторном запуске.
BEGIN;
ALTER TABLE houses
-- Идентификатор хеша (из Avito internal base64-encoded ID)
ADD COLUMN IF NOT EXISTS avito_id_hash text, -- base64 "MTE3LjM3MDg5MA"
-- Адрес (два формата)
ADD COLUMN IF NOT EXISTS short_address text, -- "Свердловская область, Екатеринбург"
ADD COLUMN IF NOT EXISTS full_address text, -- полный с улицей
-- Материалы и конструкция
ADD COLUMN IF NOT EXISTS material_walls text, -- "Монолитный" / "Железобетонные"
ADD COLUMN IF NOT EXISTS material_floors text, -- "Железобетонные перекрытия"
-- Инженерные системы
ADD COLUMN IF NOT EXISTS hot_water text, -- "Центральное" / "Автономное"
-- Парковка и придомовая территория
ADD COLUMN IF NOT EXISTS parking_type text, -- "Подземная / За шлагбаумом во дворе"
ADD COLUMN IF NOT EXISTS has_playground boolean, -- "Детская площадка"
-- Застройщик
ADD COLUMN IF NOT EXISTS developer_name text, -- "ЛСР Недвижимость" (может быть NULL)
ADD COLUMN IF NOT EXISTS developer_key text, -- Avito internal key застройщика
-- Инфраструктура
ADD COLUMN IF NOT EXISTS infrastructure_summary text, -- "Больница, детский сад, магазин, школа"
ADD COLUMN IF NOT EXISTS infrastructure_walk_distance text, -- "в 5 минутах ходьбы"
-- Рейтинг (детальный) — дополняет houses.rating (numeric(2,1))
ADD COLUMN IF NOT EXISTS rating_score numeric(4,2), -- 4.666 (точное значение до сотых)
ADD COLUMN IF NOT EXISTS rating_string text, -- "4,7" (как отображает Avito)
ADD COLUMN IF NOT EXISTS rating_distribution jsonb, -- [{score:5,count:4},{score:4,count:1},...]
-- Карта и дополнительные данные
ADD COLUMN IF NOT EXISTS map_pins jsonb, -- перезапись поля из 009 (соседние дома + POI)
ADD COLUMN IF NOT EXISTS raw_characteristics jsonb; -- весь expandParams — для retrofit новых полей
COMMENT ON COLUMN houses.rating_score IS
'Точный рейтинг до сотых (напр. 4.666). Avito округляет до 4.7 для отображения (rating_string).';
COMMENT ON COLUMN houses.rating_distribution IS
'Распределение оценок: [{score: 5, count: 4}, {score: 4, count: 1}, ...] из Houses Catalog.';
COMMENT ON COLUMN houses.raw_characteristics IS
'Сырые expandParams из Houses Catalog для retrofit новых полей без re-scrape.';
COMMIT;