gastownhall/beads · error
dropping wisp_dependencies.depends_on_id for the 0058 repair
Error message
dropping wisp_dependencies.depends_on_id for the 0058 repair: %w
What it means
Wraps a failure when dropping the generated column wisp_dependencies.depends_on_id (`ALTER TABLE wisp_dependencies DROP COLUMN depends_on_id`) during legacy-shape teardown. schemaColumnExists confirmed the column exists, but the DROP failed, aborting the repair before the surrogate key step.
Source
Thrown at internal/storage/schema/wisp_dep_forward_repair.go:365
}
hasPK, err := schemaHasPrimaryKey(ctx, db, wispDepTable)
if err != nil {
return err
}
if hasPK {
if _, err := db.ExecContext(ctx, "ALTER TABLE wisp_dependencies DROP PRIMARY KEY"); err != nil {
return fmt.Errorf("dropping the wisp_dependencies primary key for the 0058 repair: %w", err)
}
}
hasGenerated, err := schemaColumnExists(ctx, db, wispDepTable, "depends_on_id")
if err != nil {
return err
}
if hasGenerated {
if _, err := db.ExecContext(ctx, "ALTER TABLE wisp_dependencies DROP COLUMN depends_on_id"); err != nil {
return fmt.Errorf("dropping wisp_dependencies.depends_on_id for the 0058 repair: %w", err)
}
}
return nil
}
// ensureWispDepSurrogateKey adds the final shape's id column and primary key.
//
// It is added BEFORE deduplication on purpose. The natural identity of a row
// here is (issue_id, target), and two rows identical in every column have no
// deterministic survivor -- created_at has second resolution and created_by and
// type commonly take defaults, so ordinary retry inserts reach that state. Once
// every row carries a distinct UUID a delete can pick MIN(id) deterministically.
// The final primary key being the UUID also means ADD PRIMARY KEY can never
// fail on duplicates, which is the state that made the previous designs fatal.
//
// A legacy store categorically has no id column: the original 0021 created the
// composite-keyed shape without one, and ignored/0005 -- the only migration that
// adds id to a legacy store -- drops the generated column in the same guardedView on GitHub (pinned to 71377f2769)
Solutions
- Check the wrapped cause (%w) and remove any leftover index/constraint still referencing depends_on_id.
- Re-run the full guarded repair so earlier drop steps complete in order.
- Grant ALTER/DROP to the migration user and retry with no concurrent writers.
- If Dolt blocks the drop, upgrade Dolt to a version supporting the column removal and re-run `bd`.
Example fix
// before: DROP COLUMN fails — leftover index from a crashed pass
// after: drop the leftover index, then resume
// ALTER TABLE wisp_dependencies DROP INDEX <leftover>;
if err := repairWispDependenciesForwardShape(ctx, db); err != nil {
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
// check for leftover indexes/constraints referencing depends_on_id before repair
rows, err := db.QueryContext(ctx, `SELECT INDEX_NAME FROM information_schema.STATISTICS WHERE TABLE_NAME = 'wisp_dependencies' AND COLUMN_NAME = 'depends_on_id'`)
if err != nil { log.Fatalf("cannot inspect depends_on_id usage: %v", err) }
rows.Close() Try / catch
if err := repairWispDependenciesForwardShape(ctx, db); err != nil {
if strings.Contains(err.Error(), "dropping wisp_dependencies.depends_on_id") {
// drop leftover indexes/constraints on depends_on_id, then re-run the guarded repair
return fmt.Errorf("clear depends_on_id dependents and re-run: %w", err)
}
return err
} Prevention
- Confirm Dolt version supports dropping generated columns before upgrading.
- Let the repair's ordered drops (indexes → FKs → PK → column) run uninterrupted.
- Grant ALTER/DROP to the migration user.
- Avoid killing the process between drop steps; re-run the repair to resume.
When it happens
Trigger: dropWispDepLegacyShape finds depends_on_id present and the ALTER TABLE DROP COLUMN errors — column still used by an index/constraint not yet dropped, privilege denial, lock timeout, or Dolt refusing to drop a column backing existing data.
Common situations: Crashed prior repair left indexes/constraints referencing depends_on_id; user lacks ALTER; concurrent DML blocking the table; Dolt version with restricted generated-column handling.
Related errors
- pre-repair for migration %s: %w
- dropping idx_wisp_dep_type_target for the 0058 repair: %w
- dropping %s for the 0058 repair: %w
- dropping the wisp_dependencies primary key for the 0058 repa
- adding wisp_dependencies.id for the 0058 repair: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/8bd6c04ddf07ccc1.
Report an issue: GitHub.