{"record":{"id":"bfefc75cda81cbb6","repo":"gastownhall/beads","slug":"failed-to-resolve-schema-migrations-conflicts-w","errorCode":null,"errorMessage":"failed to resolve schema_migrations conflicts: %w","messagePattern":"failed to resolve schema_migrations conflicts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/mergesettle.go","lineNumber":784,"sourceCode":"\t\t\t_ = rows.Close()\n\t\t\treturn fmt.Errorf(\"scan schema_migrations conflict: %w\", err)\n\t\t}\n\t\tif ourHash.String == \"\" && theirHash.String != \"\" {\n\t\t\tfixes = append(fixes, hashFix{version: version.Int64, hash: theirHash.String})\n\t\t}\n\t}\n\tif err := errors.Join(rows.Err(), rows.Close()); err != nil {\n\t\treturn err\n\t}\n\n\tfor _, f := range fixes {\n\t\tif _, err := db.ExecContext(ctx,\n\t\t\t\"UPDATE schema_migrations SET content_hash = ? WHERE version = ?\", f.hash, f.version); err != nil {\n\t\t\treturn fmt.Errorf(\"backfill content_hash for migration %d: %w\", f.version, err)\n\t\t}\n\t}\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_CONFLICTS_RESOLVE('--ours', 'schema_migrations')\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to resolve schema_migrations conflicts: %w\", err)\n\t}\n\treturn nil\n}\n\n// resolveConflictDepTarget returns the single non-null dependency target from a\n// conflict row's three typed target columns, following the same precedence as\n// COALESCE(depends_on_issue_id, depends_on_wisp_id, depends_on_external).\nfunc resolveConflictDepTarget(issueTarget, wispTarget, external sql.NullString) (string, bool) {\n\tswitch {\n\tcase issueTarget.Valid:\n\t\treturn issueTarget.String, true\n\tcase wispTarget.Valid:\n\t\treturn wispTarget.String, true\n\tcase external.Valid:\n\t\treturn external.String, true\n\tdefault:\n\t\treturn \"\", false\n\t}","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/mergesettle.go#L766-L802","documentation":"This is the final step of auto-resolving schema_migrations merge conflicts: CALL DOLT_CONFLICTS_RESOLVE('--ours', 'schema_migrations') marks the table as resolved keeping our version. If that stored procedure call fails, this error is returned. It means the merge could not be settled on the migrations table and remains in a conflicted state.","triggerScenarios":"DOLT_CONFLICTS_RESOLVE errors — conflicts not yet fully backfilled (rows still violating constraints), unknown table in a divergent Dolt version, server refuses resolution while the merge transaction is in a bad state, or connection dropped mid-call.","commonSituations":"Dolt version without DOLT_CONFLICTS_RESOLVE or with a different argument syntax; another conflicted table blocking transaction state; interrupted merge leaving metadata inconsistent.","solutions":["Run `SHOW CREATE TABLE dolt_conflicts_schema_migrations` / check dolt_conflicts to confirm conflicts still exist, then retry the call manually.","Verify the Dolt version supports DOLT_CONFLICTS_RESOLVE with the '--ours', '<table>' argument form.","If resolution keeps failing, abort the merge (CALL DOLT_MERGE_ABORT() if a merge is in progress) and retry the pull/push.","Inspect the wrapped %w driver error for server-side details."],"exampleFix":"// before\nif _, err := db.ExecContext(ctx, \"CALL DOLT_CONFLICTS_RESOLVE('--ours', 'schema_migrations')\"); err != nil {\n    return fmt.Errorf(\"failed to resolve schema_migrations conflicts: %w\", err)\n}\n// after: abort a stuck merge and retry when resolution fails\nif _, err := db.ExecContext(ctx, \"CALL DOLT_CONFLICTS_RESOLVE('--ours', 'schema_migrations')\"); err != nil {\n    _, _ = db.ExecContext(ctx, \"CALL DOLT_MERGE_ABORT()\")\n    return fmt.Errorf(\"failed to resolve schema_migrations conflicts (merge aborted): %w\", err)\n}","handlingStrategy":"retry","validationCode":"rows, _ := db.Query(\"SELECT COUNT(*) FROM dolt_conflicts_schema_migrations\")\n// only call resolve when conflicts exist and schema_migrations reads cleanly","typeGuard":null,"tryCatchPattern":"if err := TryAutoResolveMergeConflicts(ctx, db); err != nil {\n    if strings.Contains(err.Error(), \"failed to resolve schema_migrations conflicts\") {\n        _, _ = db.ExecContext(ctx, \"CALL DOLT_MERGE_ABORT()\")\n        return retryPull(ctx) // redo the merge cleanly\n    }\n    return err\n}","preventionTips":["Keep Dolt engine version compatible with DOLT_CONFLICTS_RESOLVE","Abort and redo merges instead of forcing resolution on broken state","Run one bd process at a time during sync"],"tags":["dolt","merge-conflict","stored-procedure"],"backgroundTag":"dolt-conflicts-resolve-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}