From 40fe41bb7726911444aa6a04310c71dc467cbd35 Mon Sep 17 00:00:00 2001 From: nntrivi2001 Date: Wed, 23 Sep 2026 13:20:40 +0700 Subject: [PATCH] fix(db): keep router_profile through the legacy lanes rebuild MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The (cwd, tool) rebuild lists its columns by hand and omitted router_profile, which its probe adds earlier in the same start — a legacy DB lost the column (and every lane's router) until the next restart. --- server/__tests__/lanes-cwd-unique-rebuild.test.js | 11 +++++++++++ server/db.js | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/server/__tests__/lanes-cwd-unique-rebuild.test.js b/server/__tests__/lanes-cwd-unique-rebuild.test.js index c4939435..50a57bc7 100644 --- a/server/__tests__/lanes-cwd-unique-rebuild.test.js +++ b/server/__tests__/lanes-cwd-unique-rebuild.test.js @@ -85,6 +85,17 @@ describe("legacy lanes_new rebuild (pre-tool, single-column cwd UNIQUE DB)", () assert.equal(row.tool, "claude"); }); + it("keeps every column added before the rebuild, router_profile included", () => { + const { db } = require("../db"); + const cols = db + .prepare("PRAGMA table_info(lanes)") + .all() + .map((c) => c.name); + for (const name of ["router_profile", "needs_action_session"]) { + assert.ok(cols.includes(name), `expected ${name} to survive the rebuild`); + } + }); + it("recreates idx_lanes_session and idx_lanes_slot", () => { const { db } = require("../db"); for (const name of ["idx_lanes_session", "idx_lanes_slot"]) { diff --git a/server/db.js b/server/db.js index 11d62e18..f8ed94b3 100644 --- a/server/db.js +++ b/server/db.js @@ -645,6 +645,8 @@ try { db.exec(` PRAGMA foreign_keys = OFF; BEGIN; + -- Every column the probes ABOVE this block add must be listed here too, + -- or the rebuild silently drops it (router_profile once was). CREATE TABLE lanes_new ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL DEFAULT '', @@ -669,6 +671,7 @@ try { base_branch TEXT, slug TEXT, tool TEXT NOT NULL DEFAULT 'claude', + router_profile TEXT, detected_stage TEXT, detected_signal TEXT, detected_at TEXT, @@ -679,7 +682,7 @@ try { INSERT INTO lanes_new SELECT id, title, cwd, branch, pipeline, session_id, run_id, stage, stage_since, status, gate_decision, ci_status, needs_action, links, stages, notes, - created_at, updated_at, kind, source_repo, base_branch, slug, tool, + created_at, updated_at, kind, source_repo, base_branch, slug, tool, router_profile, detected_stage, detected_signal, detected_at, slot, ports, active_feature_id FROM lanes; DROP TABLE lanes;