{"record":{"id":"8fe4189b6f34b160","repo":"gastownhall/beads","slug":"dolt-add-s-w-8fe418","errorCode":null,"errorMessage":"dolt add %s: %w","messagePattern":"dolt add (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/schema.go","lineNumber":970,"sourceCode":"\tif err != nil {\n\t\treturn false, err\n\t}\n\tfor table := range tablesAfter {\n\t\tif _, wasDirty := dirtyBefore[table]; wasDirty {\n\t\t\tcontinue\n\t\t}\n\t\ttableSet[table] = struct{}{}\n\t}\n\n\ttables := make([]string, 0, len(tableSet))\n\tfor table := range tableSet {\n\t\ttables = append(tables, table)\n\t}\n\tsort.Strings(tables)\n\n\tfor _, table := range tables {\n\t\tif err := DrainCall(ctx, db, \"CALL DOLT_ADD('-f', ?)\", table); err != nil {\n\t\t\treturn false, fmt.Errorf(\"dolt add %s: %w\", table, err)\n\t\t}\n\t}\n\treturn len(tables) > 0, nil\n}\n\nfunc existingCommittableTables(ctx context.Context, db DBConn) (map[string]struct{}, error) {\n\trows, err := db.QueryContext(ctx, `\n\t\tSELECT t.TABLE_NAME\n\t\tFROM INFORMATION_SCHEMA.TABLES t\n\t\tWHERE t.TABLE_SCHEMA = DATABASE()\n\t\t  AND t.TABLE_TYPE = 'BASE TABLE'\n\t\t  AND NOT EXISTS (\n\t\t\tSELECT 1 FROM dolt_ignore di\n\t\t\tWHERE di.ignored = 1\n\t\t\t  AND t.TABLE_NAME LIKE di.pattern\n\t\t  )\n\t`)\n\tif err != nil {","sourceCodeStart":952,"sourceCodeEnd":988,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/schema.go#L952-L988","documentation":"stageSchemaTables wraps a failure from the `CALL DOLT_ADD('-f', ?)` stored-procedure invocation that force-stages a table into the Dolt working set during migration. DOLT_ADD is Dolt's SQL equivalent of `dolt add`; if the procedure call itself errors (bad table name, session/catalog issues, procedure unavailable), the error is wrapped as `dolt add <table>: <cause>` so the failing table is identified.","triggerScenarios":"Called from MigrateUp after running migrations, or directly by TestStageSchemaTablesSkipsIgnoredTables. The CALL fails for a table that became newly-dirty or newly-committable (present in dolt_status or existingCommittableTables and not dirty before) — e.g. the table was dropped mid-migration, DOLT_ADD is unavailable/wrong-case on the server, or the connection session is in a bad state after a prior failed statement.","commonSituations":"A migration step creates then drops a temp table so it is dirty but gone by staging time; running against a non-Dolt MySQL backend where the DOLT_ADD procedure does not exist; Dolt version downgrades where the '-f' flag or procedure arity is unsupported; connection drops mid-migration.","solutions":["Inspect the wrapped cause: if the table no longer exists, re-run the migration — staging recomputes dirty tables at start and will skip it.","Verify the backend is Dolt and the dolt server version supports CALL DOLT_ADD with '-f'; upgrade the Dolt server if not.","Check the connection is healthy (no prior poisoned-catalog-snapshot statement in the session); open a fresh connection and retry MigrateUp.","If DOLT_ADD is unsupported in your environment, ensure the table is committed via an alternative path before MigrateUp completes."],"exampleFix":"// before\nif err := DrainCall(ctx, db, \"CALL DOLT_ADD('-f', ?)\", table); err != nil {\n    return false, fmt.Errorf(\"dolt add %s: %w\", table, err)\n}\n// after\nif err := DrainCall(ctx, db, \"CALL DOLT_ADD('-f', ?)\", table); err != nil {\n    if dberrors.IsTableNotExist(err) {\n        continue // table vanished mid-migration; nothing to stage\n    }\n    return false, fmt.Errorf(\"dolt add %s: %w\", table, err)\n}","handlingStrategy":"retry","validationCode":"// before MigrateUp: ensure backend is Dolt and procedure exists\nvar one int\nif err := db.QueryRowContext(ctx, \"SELECT COUNT(*) FROM information_schema.routines WHERE routine_name = 'dolt_add'\").Scan(&one); err != nil || one == 0 {\n    return fmt.Errorf(\"DOLT_ADD procedure unavailable on this backend\")\n}","typeGuard":"func isDoltProcMissing(err error) bool {\n    var mysqlErr *mysql.MySQLError\n    return errors.As(err, &mysqlErr) && (mysqlErr.Number == 1305 /* PROCEDURE does not exist */)\n}","tryCatchPattern":"err := MigrateUp(ctx, db)\nvar doltErr error\nif errors.As(err, &doltErr) && strings.Contains(err.Error(), \"dolt add \") {\n    log.Printf(\"staging failed for table; retrying migration: %v\", err)\n    err = MigrateUp(ctx, freshDB())\n}","preventionTips":["Run migrations against a live, healthy Dolt server (not a plain MySQL backend).","Re-run MigrateUp on failure — it recomputes dirty tables and is safe to retry.","Avoid dropping tables mid-migration that later steps expect to stage.","Keep the Dolt server version current so DOLT_ADD('-f', ...) is supported."],"tags":["database","dolt","migration","staging"],"backgroundTag":"dolt-add-staging-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}