{"record":{"id":"b5b9446985a64b00","repo":"gastownhall/beads","slug":"checking-issues-s-w","errorCode":null,"errorMessage":"checking issues.%s: %w","messagePattern":"checking issues\\.(.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/migration_repairs.go","lineNumber":588,"sourceCode":"// added to the squashed bootstrap 0001_create_issues, so a database\n// bootstrapped before they existed reaches schema v52 without them, and\n// migration 0053 — which copies exactly these columns from wisps into\n// issues — fails with \"Unknown column\" even with zero rig wisps to repair.\n// Databases in the wild may have some but not all six, so each is checked\n// individually. Definitions mirror the current bootstrap schema.\nfunc ensureIssuesRigColumns(ctx context.Context, db DBConn) error {\n\tcolumns := []struct{ name, definition string }{\n\t\t{\"hook_bead\", \"VARCHAR(255) DEFAULT ''\"},\n\t\t{\"role_bead\", \"VARCHAR(255) DEFAULT ''\"},\n\t\t{\"agent_state\", \"VARCHAR(32) DEFAULT ''\"},\n\t\t{\"last_activity\", \"DATETIME\"},\n\t\t{\"role_type\", \"VARCHAR(32) DEFAULT ''\"},\n\t\t{\"rig\", \"VARCHAR(255) DEFAULT ''\"},\n\t}\n\tfor _, col := range columns {\n\t\tpresent, err := schemaColumnExists(ctx, db, \"issues\", col.name)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"checking issues.%s: %w\", col.name, err)\n\t\t}\n\t\tif present {\n\t\t\tcontinue\n\t\t}\n\t\tif _, err := db.ExecContext(ctx, \"ALTER TABLE issues ADD COLUMN \"+col.name+\" \"+col.definition); err != nil {\n\t\t\treturn fmt.Errorf(\"adding issues.%s for migration 0053: %w\", col.name, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// ensureWispDependenciesSplitTargets repairs #4555: a mixed-vintage local\n// wisp_dependencies table can have the post-0005 id column while still lacking\n// one or more split target columns. Migration 0053 reads those columns when it\n// repairs rig wisps, so add the missing columns and backfill them from the\n// legacy depends_on_id column when that source column is still available.\n//\n// Column presence is not, by itself, proof the backfill below ever ran: a","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/migration_repairs.go#L570-L606","documentation":"Wraps failure of the `schemaColumnExists(ctx, db, \"issues\", col.name)` probe used by ensureIssuesRigColumns while checking whether each 0053 rig column (role_type, rig) already exists on `issues`. An introspection failure here aborts the column-ensure step.","triggerScenarios":"repairV53RigAndSplitTargets (and its test) runs during startup; the information_schema existence check for `issues.role_type` or `issues.rig` errors — server unreachable, permission denied on metadata, transient connection failure.","commonSituations":"Dolt server down during upgrade; restricted DB user; interrupted/duplicated schema repair where a previous run left the connection pool stale.","solutions":["Rerun `bd`; the check is read-only and idempotent","Fix the wrapped %w cause (start server, repair credentials/network)","Confirm the user can read information_schema.COLUMNS for the `issues` table","If a previous run crashed, restart the Dolt server cleanly before retrying"],"exampleFix":"// before: stale Dolt daemon after crash\nbd dolt server restart\n// after\nbd ready","handlingStrategy":"retry","validationCode":"bd dolt sql -q \"SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_NAME='issues' AND COLUMN_NAME IN ('role_type','rig')\" || echo 'introspection unavailable'","typeGuard":null,"tryCatchPattern":"if err := ensureSchema(ctx, db); err != nil {\n    if strings.Contains(err.Error(), \"checking issues.\") && transient(err) {\n        return retryWithBackoff(ensureSchema)\n    }\n    return err\n}","preventionTips":["Restart a crashed Dolt server cleanly before retrying migrations","Grant information_schema read access to the bd account","Avoid stacking concurrent bd invocations during upgrades","Verify connectivity before long schema repairs"],"tags":["database","migration","introspection","sql"],"backgroundTag":"schema-introspection-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}