From e4f4f031ef0a21f3ea994fe03bceed2ba6094a32 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Tue, 25 Aug 2026 13:08:50 +0000 Subject: [PATCH] Fix: migrate forecast_points.wind_dir_deg on existing deployments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CREATE TABLE IF NOT EXISTS is a no-op against a table that already exists — it doesn't add columns introduced after the first deploy. The live LXC's forecast_points was created before wind_dir_deg existed, so every insert in lib/weather-fetch.js has been failing with 'column wind_dir_deg of relation forecast_points does not exist' since that feature landed. Co-Authored-By: Claude Sonnet 5 --- backend/src/db.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/src/db.js b/backend/src/db.js index fc5e7b5..2463031 100644 --- a/backend/src/db.js +++ b/backend/src/db.js @@ -60,6 +60,13 @@ export async function initDb() { updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); `) + + // wind_dir_deg was added to forecast_points after the first deploy already ran — + // CREATE TABLE IF NOT EXISTS above is a no-op against an existing table, it does + // NOT retroactively add new columns, so this needs its own explicit migration. + // forecast_astro/config didn't need this since they're whole new tables, which + // CREATE TABLE IF NOT EXISTS does handle correctly on an existing database. + await pool.query(`ALTER TABLE forecast_points ADD COLUMN IF NOT EXISTS wind_dir_deg NUMERIC`) } export async function getStatus() {