From d8f79c1912eccdc2c65679c4f60603f98f5eece2 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sat, 4 Jul 2026 09:56:07 +0000 Subject: fix(storage): add ALTER TABLE migrations for stories columns added in schema redesign MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The live DB has a stories table created before the full schema was established. CREATE TABLE IF NOT EXISTS is a no-op on those DBs, so epic_id, discovery_source, spec, acceptance_criteria_json, priority, and root_task_id never landed — causing the CREATE INDEX on epic_id to fail with "no such column" on startup. Add an ALTER TABLE migration for each missing column, relying on the existing isColumnExistsError guard for idempotency on fresh DBs. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01DNDHfCtTZDbQueEV5sUBiD --- internal/storage/db.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'internal/storage/db.go') diff --git a/internal/storage/db.go b/internal/storage/db.go index 51ea648..4eebd04 100644 --- a/internal/storage/db.go +++ b/internal/storage/db.go @@ -180,6 +180,15 @@ func (s *DB) migrate() error { created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL )`, + // Additive columns for DBs created before the full stories schema was + // established. CREATE TABLE IF NOT EXISTS is a no-op on old DBs, so each + // new column needs its own ALTER TABLE to land on existing tables. + `ALTER TABLE stories ADD COLUMN epic_id TEXT`, + `ALTER TABLE stories ADD COLUMN discovery_source TEXT`, + `ALTER TABLE stories ADD COLUMN spec TEXT`, + `ALTER TABLE stories ADD COLUMN acceptance_criteria_json TEXT NOT NULL DEFAULT '[]'`, + `ALTER TABLE stories ADD COLUMN priority TEXT`, + `ALTER TABLE stories ADD COLUMN root_task_id TEXT`, `CREATE INDEX IF NOT EXISTS idx_epics_status ON epics(status)`, `CREATE INDEX IF NOT EXISTS idx_stories_status ON stories(status)`, `CREATE INDEX IF NOT EXISTS idx_stories_epic_id ON stories(epic_id)`, -- cgit v1.2.3