-- Drop legacy `use_rosreestr2coord` column from nspd_geo_jobs. -- -- Контекст: -- В первой итерации NSPD geo bulk-fetcher был выбор между нашим urllib-fetcher -- (fetch_geoportal) и community-библиотекой rosreestr2coord. На практике -- библиотека намного устойчивее к WAF — её авторы регулярно обновляют -- headers/tricks. Поэтому отказались от urllib-ветки и теперь ВСЕГДА используем -- rosreestr2coord. Колонка больше не несёт смысла. -- -- Порядок: сначала пересоздаём v_scrape_runs_unified без зависимости от -- колонки, потом DROP COLUMN. BEGIN; -- Чистим возможную мусорную view с опечаткой (создавалась предыдущей попыткой -- миграции — без 's' в имени, ошибка). DROP VIEW IF EXISTS v_scrape_run_unified; -- Главная unified-view (см. 77_nspd_geo_jobs.sql) пересоздаётся без -- use_rosreestr2coord в JSONB-секции nspd_geo. CREATE OR REPLACE VIEW v_scrape_runs_unified AS SELECT 'kn' AS scraper_type, run_id, started_at, finished_at, heartbeat_at, status, error, NULL::text AS triggered_by, region_codes::text AS scope, requests_count, objects_count AS items_ok, NULL::integer AS items_failed, flats_count AS sub_items_ok, progress_obj_index AS progress_idx, total_obj_count AS progress_total, jsonb_build_object('developers', developer_ids, 'snapshot_date', snapshot_date, 'resumed_from', resumed_from_run_id, 'params', params) AS extra FROM kn_scrape_runs UNION ALL SELECT 'nspd', run_id, started_at, finished_at, heartbeat_at, status, error, triggered_by, region_code::text, requests_count, quarters_ok, quarters_failed, buildings_ok, NULL, pending_count, jsonb_build_object('waf_429_count', waf_429_count) FROM nspd_scrape_runs UNION ALL SELECT 'objective', run_id, started_at, finished_at, heartbeat_at, status, error, triggered_by, group_name, requests_count, reports_ok, reports_failed, rows_lots, NULL, NULL, jsonb_build_object('rows_corpus_room', rows_corpus_room, 'rows_history', rows_history) FROM objective_scrape_runs UNION ALL SELECT 'nspd_geo', job_id, started_at, finished_at, heartbeat_at, status, error, triggered_by, COALESCE(name, job_kind), requests_count, targets_done, targets_failed, targets_skipped, targets_done, targets_total, jsonb_build_object('job_kind', job_kind, 'source_kind', source_kind, 'rate_ms', rate_ms, 'waf_blocked_count', waf_blocked_count, 'source_params', source_params) FROM nspd_geo_jobs; ALTER TABLE nspd_geo_jobs DROP COLUMN IF EXISTS use_rosreestr2coord; COMMIT;