summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-04 09:56:07 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-04 09:56:07 +0000
commitd8f79c1912eccdc2c65679c4f60603f98f5eece2 (patch)
treef4c6391d133cd53e7fce37071d4e3e36a689e82e
parent26366e8465e7e4ab3be9362f59e86564cf68db63 (diff)
fix(storage): add ALTER TABLE migrations for stories columns added in schema redesign
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DNDHfCtTZDbQueEV5sUBiD
-rw-r--r--internal/storage/db.go9
1 files changed, 9 insertions, 0 deletions
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)`,