diff --git a/deploy/deploy.sh b/deploy/deploy.sh index e9f5dbf..53d9515 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -43,6 +43,15 @@ fi .venv/bin/pip install --upgrade pip -q .venv/bin/pip install -r backend/requirements.txt -q +# Apply any pending accounts-DB schema migrations before the new code starts, so +# it never queries a column an older database lacks. Idempotent and tracked, so +# every deploy can run it; sourcing the env picks up a THERMOGRAPH_ACCOUNTS_DB +# override if one is set. Runs as the deploy user, who owns the data dir. +echo "==> Applying database migrations" +( set -a; . /etc/thermograph.env 2>/dev/null || true; set +a + "$APP_DIR/.venv/bin/python" "$APP_DIR/deploy/migrate-db.py" +) + echo "==> Restarting service" sudo systemctl restart thermograph