{"record":{"id":"c39268709eb49528","repo":"gastownhall/beads","slug":"unknown-column-content-hash-in-schema-migrations-a","errorCode":null,"errorMessage":"unknown column content_hash in schema_migrations at %q","messagePattern":"unknown column content_hash in schema_migrations at %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/storage/schema/migration_content_hashes.go","lineNumber":72,"sourceCode":"\t\t// it: letting the SELECT fail emits a Dolt server warning for every\n\t\t// read-only doctor run.\n\t\t//nolint:gosec // G201: ref is validated above — AS OF requires a literal, not a bind param\n\t\thasTable, queryErr := queryHasRows(ctx, db,\n\t\t\tfmt.Sprintf(\"SHOW TABLES AS OF '%s' LIKE 'schema_migrations'\", ref))\n\t\tif queryErr != nil {\n\t\t\treturn nil, queryErr\n\t\t}\n\t\tif !hasTable {\n\t\t\treturn nil, fmt.Errorf(\"table not found: schema_migrations at %q\", ref)\n\t\t}\n\t\t//nolint:gosec // G201: ref is validated above — AS OF requires a literal, not a bind param\n\t\thasContentHash, queryErr := queryHasRows(ctx, db,\n\t\t\tfmt.Sprintf(\"SHOW COLUMNS FROM schema_migrations AS OF '%s' LIKE 'content_hash'\", ref))\n\t\tif queryErr != nil {\n\t\t\treturn nil, queryErr\n\t\t}\n\t\tif !hasContentHash {\n\t\t\treturn nil, fmt.Errorf(\"unknown column content_hash in schema_migrations at %q\", ref)\n\t\t}\n\t\t//nolint:gosec // G201: ref is validated above — AS OF requires a literal, not a bind param\n\t\trows, err = db.QueryContext(ctx,\n\t\t\tfmt.Sprintf(\"SELECT version, content_hash FROM schema_migrations AS OF '%s'\", ref))\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tout := map[int]string{}\n\tfor rows.Next() {\n\t\tvar version int\n\t\tvar hash sql.NullString\n\t\tif err := rows.Scan(&version, &hash); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif hash.Valid && hash.String != \"\" {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/migration_content_hashes.go#L54-L90","documentation":"After confirming schema_migrations exists at the ref, the code probes \"SHOW COLUMNS ... LIKE 'content_hash'\"; if the column is absent at that commit, this error is returned. It means the ref predates the content_hash column addition — schema existed but the newer column hadn't been migrated in yet.","triggerScenarios":"Calling ReadMigrationContentHashes with a ref where schema_migrations exists but lacks the content_hash column (intermediate schema history); comparing against a remote that hasn't pulled the content-hash migration.","commonSituations":"Mixed-version deployments where one replica/repo has newer migrations than the ref being compared; doctor run against an out-of-date remote branch; partially applied migration history.","solutions":["Update the ref to a commit at or after the content_hash migration (e.g. latest remote main).","Run `bd dolt pull` / sync the remote so it contains the newer migration, then retry.","If old history must be handled, catch this case and treat content hashes as absent for that ref.","Apply pending migrations so both sides share the content_hash column."],"exampleFix":"// before: fail on old remote\nhashes, err := schema.ReadMigrationContentHashes(ctx, db, ref)\n// after: treat column-less history as empty hashes\nhashes, err := schema.ReadMigrationContentHashes(ctx, db, ref)\nif err != nil && strings.Contains(err.Error(), \"unknown column content_hash\") {\n    return map[string]string{}, nil\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"hashes, err := schema.ReadMigrationContentHashes(ctx, db, ref)\nif err != nil && strings.Contains(err.Error(), \"unknown column content_hash\") {\n    hashes = map[string]string{} // ref predates content_hash column\n}","preventionTips":["Keep all replicas/repos migrated to the same schema version before comparing.","Sync the remote (`bd dolt pull`) before doctor comparisons.","Treat column-less history as empty hashes when diffing against old refs."],"tags":["database","dolt","migration","schema-versioning"],"backgroundTag":"schema-migrations-missing-at-ref","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}