fix(db): keep router_profile through the legacy lanes rebuild

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.
This commit is contained in:
2026-09-23 13:20:40 +07:00
parent 99a2a8277c
commit 40fe41bb77
2 changed files with 15 additions and 1 deletions
@@ -85,6 +85,17 @@ describe("legacy lanes_new rebuild (pre-tool, single-column cwd UNIQUE DB)", ()
assert.equal(row.tool, "claude"); 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", () => { it("recreates idx_lanes_session and idx_lanes_slot", () => {
const { db } = require("../db"); const { db } = require("../db");
for (const name of ["idx_lanes_session", "idx_lanes_slot"]) { for (const name of ["idx_lanes_session", "idx_lanes_slot"]) {
+4 -1
View File
@@ -645,6 +645,8 @@ try {
db.exec(` db.exec(`
PRAGMA foreign_keys = OFF; PRAGMA foreign_keys = OFF;
BEGIN; 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 ( CREATE TABLE lanes_new (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL DEFAULT '', title TEXT NOT NULL DEFAULT '',
@@ -669,6 +671,7 @@ try {
base_branch TEXT, base_branch TEXT,
slug TEXT, slug TEXT,
tool TEXT NOT NULL DEFAULT 'claude', tool TEXT NOT NULL DEFAULT 'claude',
router_profile TEXT,
detected_stage TEXT, detected_stage TEXT,
detected_signal TEXT, detected_signal TEXT,
detected_at TEXT, detected_at TEXT,
@@ -679,7 +682,7 @@ try {
INSERT INTO lanes_new SELECT INSERT INTO lanes_new SELECT
id, title, cwd, branch, pipeline, session_id, run_id, stage, stage_since, id, title, cwd, branch, pipeline, session_id, run_id, stage, stage_since,
status, gate_decision, ci_status, needs_action, links, stages, notes, 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 detected_stage, detected_signal, detected_at, slot, ports, active_feature_id
FROM lanes; FROM lanes;
DROP TABLE lanes; DROP TABLE lanes;