{"record":{"id":"a30fc7528d1281ca","repo":"gastownhall/beads","slug":"creating-wisp-dependencies-for-migration-0047-w","errorCode":null,"errorMessage":"creating wisp_dependencies for migration 0047: %w","messagePattern":"creating wisp_dependencies for migration 0047: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/migration_repairs.go","lineNumber":216,"sourceCode":"// (lease columns added then removed again) or 56 belongs here.\nfunc ensureWispTablesForMixedBlockedRecompute(ctx context.Context, db DBConn) error {\n\thasWisps, err := schemaTableExists(ctx, db, \"wisps\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"checking wisps table: %w\", err)\n\t}\n\tif !hasWisps {\n\t\tif _, err := db.ExecContext(ctx, wispsTableDDLForMigration0047); err != nil {\n\t\t\treturn fmt.Errorf(\"creating wisps for migration 0047: %w\", err)\n\t\t}\n\t}\n\n\thasWispDeps, err := schemaTableExists(ctx, db, \"wisp_dependencies\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"checking wisp_dependencies table: %w\", err)\n\t}\n\tif !hasWispDeps {\n\t\tif _, err := db.ExecContext(ctx, wispDependenciesTableDDLForMigration0047); err != nil {\n\t\t\treturn fmt.Errorf(\"creating wisp_dependencies for migration 0047: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn ensureWispDependenciesSplitTargets(ctx, db)\n}\n\n// ensureWispIsBlockedForRecompute repairs a drift shape in ignored/0006's own\n// guard: it no-ops (SELECT 1) when wisps does not exist yet at the moment it\n// runs, and once the ignored cursor advances past 6 that migration is never\n// pending again (pending = version > MAX(cursor); a missing low-numbered row\n// does not lower the high-water mark). wisps can be materialized without\n// is_blocked several ways -- ignored/0001's own CREATE-then-RENAME leaves an\n// existing wisps table untouched, and the main-side 0047 repair above\n// creates wisps at the wispsTableDDLForMigration0047 shape, which has no\n// is_blocked column, whenever the main pass reaches version 47 with wisps\n// entirely missing. Whichever path, a clone that ends up there permanently\n// lacks the column, and BOTH ignored/0007 and ignored/0015's frozen","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/migration_repairs.go#L198-L234","documentation":"When wisp_dependencies is missing, the repair creates it from wispDependenciesTableDDLForMigration0047 — the split-target shape with foreign keys to wisps and issues. This error wraps failure of that CREATE TABLE: most commonly a missing/mismatched FK target, a connection drop mid-DDL, or Dolt rejecting a DDL feature (CHECK constraint, UUID() expression default).","triggerScenarios":"Clone reaching 0047 with wisp_dependencies absent; CREATE TABLE fails because wisps/issues are missing or drifted (FK targets), the connection dropped, or the Dolt server does not support a DDL feature used.","commonSituations":"Clone-skew after a schema bump; older Dolt server lacking feature support; interrupted prior init leaving wisps created but wisp_dependencies not; drifted issues table missing FK target columns.","solutions":["Retry bd init — the DDL is CREATE TABLE IF NOT EXISTS and idempotent","Verify the FK target tables (wisps, issues) exist with an id column; the wisps branch runs first in the same repair","Check the Dolt server version supports CHECK constraints and expression defaults; upgrade if not","Inspect the wrapped SQL error for the failing clause (FK vs CHECK vs connection)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure FK targets exist before the DDL can succeed\nfor _, t := range []string{\"wisps\", \"issues\"} {\n    var n int\n    db.QueryRowContext(ctx, `SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES\n      WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?`, t).Scan(&n)\n    if n == 0 { return fmt.Errorf(\"FK target %s missing; cannot create wisp_dependencies\", t) }\n}","typeGuard":null,"tryCatchPattern":"if _, err := db.ExecContext(ctx, wispDependenciesTableDDLForMigration0047); err != nil {\n    if isUnsupportedDDL(err) { // CHECK constraint / expression default rejected\n        return fmt.Errorf(\"upgrade Dolt server: %w\", err)\n    }\n    return err\n}","preventionTips":["Verify Dolt server version supports CHECK constraints and expression defaults before upgrading","Ensure the wisps branch of the repair ran first — it creates the FK target","Retry after transient failures; DDL is CREATE TABLE IF NOT EXISTS","Check for stale conflicting objects before re-running init"],"tags":["dolt","migration","ddl","foreign-key"],"backgroundTag":"table-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}