From d46695ba50a7c6e4f42f21cf53e378d11c3b4251 Mon Sep 17 00:00:00 2001 From: lekss361 Date: Wed, 17 Jun 2026 20:02:06 +0000 Subject: [PATCH] =?UTF-8?q?fix(sql):=20ALTER=20TABLE=20IF=20EXISTS=20in=20?= =?UTF-8?q?migration=20162=20=E2=80=94=20district=5Feconomics=20absent=20o?= =?UTF-8?q?n=20main=20DB=20(deploy=20red)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/sql/162_drop_district_economics_sat_factor.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/data/sql/162_drop_district_economics_sat_factor.sql b/data/sql/162_drop_district_economics_sat_factor.sql index e36e0586..47c6044a 100644 --- a/data/sql/162_drop_district_economics_sat_factor.sql +++ b/data/sql/162_drop_district_economics_sat_factor.sql @@ -5,8 +5,14 @@ -- The live market sub-score uses sat_score = min(100, sold_pct * 100 / 70) directly, -- so sat_factor double-counts absorption without being applied anywhere. -- All code references removed in the same commit as this migration. +-- +-- NB: ALTER TABLE *IF EXISTS* — district_economics is created by the site-finder +-- pipeline (09_macro_and_trend.py / server.py), NOT by data/sql migrations, so it may +-- be absent on the main Postgres. Without IF EXISTS the deploy fails with +-- "relation district_economics does not exist" (DROP COLUMN IF EXISTS only guards the +-- column, not the table). Idempotent + safe when the table is absent. BEGIN; -ALTER TABLE district_economics DROP COLUMN IF EXISTS sat_factor; +ALTER TABLE IF EXISTS district_economics DROP COLUMN IF EXISTS sat_factor; COMMIT;