{"record":{"id":"c78d1076859a3421","repo":"gastownhall/beads","slug":"embeddeddolt-migrate-w","errorCode":null,"errorMessage":"embeddeddolt: migrate: %w","messagePattern":"embeddeddolt: migrate: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/store.go","lineNumber":452,"sourceCode":"\t\t\t// so both non-strict intents warn and continue on the current\n\t\t\t// schema instead of failing the open.\n\t\t\tswitch s.intent {\n\t\t\tcase openWorkingSetReconcile:\n\t\t\t\tfmt.Fprintf(os.Stderr,\n\t\t\t\t\t\"Warning: %v\\n\"+\n\t\t\t\t\t\t\"  Committing the working set at the current schema; when it completes,\\n\"+\n\t\t\t\t\t\t\"  re-run 'bd migrate'.\\n\",\n\t\t\t\t\tdirtyErr)\n\t\t\tdefault: // openReadOnlyCommand\n\t\t\t\tfmt.Fprintf(os.Stderr,\n\t\t\t\t\t\"Warning: %v\\n\"+\n\t\t\t\t\t\t\"  Continuing without migrating. Run 'bd dolt commit' to commit the\\n\"+\n\t\t\t\t\t\t\"  working set at the current schema, then re-run 'bd migrate'.\\n\",\n\t\t\t\t\tdirtyErr)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"embeddeddolt: migrate: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// GetIssue is implemented in get_issue.go.\n\nfunc (s *EmbeddedDoltStore) GetIssueByExternalRef(ctx context.Context, externalRef string) (*types.Issue, error) {\n\tvar id string\n\terr := s.withConn(ctx, false, func(tx *sql.Tx) error {\n\t\tvar err error\n\t\tid, err = issueops.GetIssueByExternalRefInTx(ctx, tx, externalRef)\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn s.GetIssue(ctx, id)","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/store.go#L434-L470","documentation":"Returned by initSchema when schema.MigrateUp fails to apply pending schema migrations to the embedded database. Before this, initSchema has already done a forward-drift guard (database schema newer than the binary gets an explicit 'upgrade bd' message), so reaching this wrapper means MigrateUp itself errored on applying migrations — SQL failure mid-migration, context cancellation, dirty migration state with uncommitted working-set changes, or engine errors. The database may be left in a partially migrated state.","triggerScenarios":"newStore -> initSchema where MigrateUp returns an error other than the handled dirty-working-set case: (1) a migration statement fails (engine incompatibility, corrupt schema_version table); (2) context cancelled during a long migration; (3) dirty migration state where the working-set bailout path doesn't apply and the raw error is wrapped.","commonSituations":"Upgrading bd across many schema versions at once; interrupting a previous migration (kill/Ctrl-C) leaving partial state; running a newer database with an older binary in a way the drift guard missed (e.g. same-time edits); huge issue databases making migrations exceed the context deadline.","solutions":["Read the wrapped inner error (%w) for the exact failing migration and SQL error.","Run 'bd doctor' to check and repair migration/schema state.","Commit or clean the Dolt working set ('bd dolt commit') then re-run 'bd migrate' as the error text above suggests.","Upgrade bd to the latest version so its migrations match the database schema era.","If partially migrated and unrecoverable, restore the data dir from git/Dolt remote or backup before retrying."],"exampleFix":"// before\nbd open  # embeddeddolt: migrate: dirty working set ... \n\n// after\nbd dolt commit   # commit working set at current schema\nbd migrate       # apply migrations explicitly, then open normally","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := store.Init(ctx); err != nil && strings.Contains(err.Error(), \"embeddeddolt: migrate\") {\n    // 1) commit working set at current schema\n    exec.Command(\"bd\", \"dolt\", \"commit\").Run()\n    // 2) migrate explicitly, then retry init\n    exec.Command(\"bd\", \"migrate\").Run()\n    err = store.Init(ctx)\n    return err\n}","preventionTips":["Never kill bd mid-migration; let 'bd migrate' finish","Upgrade bd through each documented step rather than skipping many versions","Keep the Dolt remote in sync so the data dir can be restored","Run 'bd doctor' before/after major upgrades"],"tags":["embedded-dolt","migration","schema"],"backgroundTag":"schema-migration-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}