gendesign/tradein-mvp/backend/data/sql/121_yandex_rich_fields.sql
bot-backend 1fe670ea6a
All checks were successful
CI / changes (pull_request) Successful in 6s
CI / backend-tests (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Has been skipped
feat(yandex): map rich entity fields (predictedPrice, seller, listing_date, trend, metro)
2026-06-17 22:58:16 +03:00

30 lines
1.7 KiB
PL/PgSQL
Raw 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.

-- Migration 121: Yandex gate-API rich entity fields the parser previously dropped.
--
-- Источник: realty.yandex.ru/gate/react-page/get/ entity object содержит ~90 полей,
-- из которых маппилось ~11. Эта миграция добавляет колонки под high-value поля:
--
-- predictedPrice.predictedPrice.{value,min,max} → собственная оценка Яндекса
-- per-offer (рыночная цена) — headline-выигрыш для estimator/анализа bargain.
-- price.trend / price.previous → динамика цены объявления.
--
-- description / listing_date / publish_date / days_on_market / metro_stations /
-- is_homeowner / is_pro_seller / agency_name / yandex_offer_id — уже существуют
-- в listings (миграции 011 / 033 и др.); эта миграция их НЕ трогает, парсер просто
-- начинает их наполнять (см. base.py save_listings + yandex_realty._entity_to_lot).
--
-- Idempotent: ADD COLUMN IF NOT EXISTS. Авто-применяется на деплое.
BEGIN;
ALTER TABLE listings ADD COLUMN IF NOT EXISTS predicted_price_rub bigint;
ALTER TABLE listings ADD COLUMN IF NOT EXISTS predicted_price_min bigint;
ALTER TABLE listings ADD COLUMN IF NOT EXISTS predicted_price_max bigint;
ALTER TABLE listings ADD COLUMN IF NOT EXISTS price_trend text;
ALTER TABLE listings ADD COLUMN IF NOT EXISTS price_previous_rub bigint;
COMMENT ON COLUMN listings.predicted_price_rub IS
'Yandex per-offer valuation (predictedPrice.predictedPrice.value), RUB';
COMMENT ON COLUMN listings.price_trend IS
'Yandex price.trend: INCREASED / DECREASED / UNCHANGED / ...';
COMMIT;