Skip to content

init --migrate-only crashes with "column 'provider_id' does not exist": v0.22.0 → v0.27.0 wedge on schema-v29 PGLite brain #670

@riedelrobert-cyber

Description

@riedelrobert-cyber

Summary

Upgrading from gbrain 0.22.0 (commit 172b55b, source-linked install via bun link) to 0.27.0 (commit ee9ceb3, master HEAD as of 2026-05-06): gbrain init --migrate-only crashes with column "provider_id" does not exist after the bootstrap probe announces "Pre-v0.21 brain detected" — even though gbrain doctor confirmed schema_version 29 (latest 29) before the upgrade.

This looks like the same wedge-cycle class addressed by v0.22.6.1, but the bootstrap probe is mis-classifying a modern brain (schema v29) and applying pre-v0.21 forward-references that crash on the new v0.27 provider_id column.

Likely related: #615 (agent_name on schema v24 → v34), #609 (mcp_request_log columns on PGLite v0.26.6).

Environment

  • gbrain (pre-upgrade): 0.22.0 source @ commit 172b55b — binary self-reported 0.21.0 due to the package.json version-bump bug fixed in 0.27.0
  • gbrain (target): 0.27.0 (commit ee9ceb3)
  • Install method: local clone at ~/gbrain/ linked via bun link (~/.bun/install/global/node_modules/gbrain~/gbrain, bin → src/cli.ts)
  • Engine: PGLite
  • Pre-upgrade: 1788 pages, schema_version 29 (latest 29 at v0.22.0)
  • Target schema_version per apply-migrations output: 36
  • Bun: 1.3.13
  • OS: macOS Darwin 25.1.0

Pre-upgrade state (doctor --json, key fields only)

{
  "schema_version": 2,
  "status": "warnings",
  "health_score": 70,
  "checks": [
    {"name": "connection", "status": "ok", "message": "Connected, 1788 pages"},
    {"name": "schema_version", "status": "ok", "message": "Version 29 (latest: 29)"},
    {"name": "embeddings", "status": "ok", "message": "100% coverage, 1 missing"},
    {"name": "rls", "status": "ok", "message": "Skipped (PGLite — no PostgREST exposure, RLS not applicable)"}
  ]
}

The schema_version check explicitly reports "Version 29 (latest: 29)" — not pre-v0.21.

Repro

# Starting state: gbrain at SHA 172b55b (v0.22.0), brain at schema v29
gbrain doctor --json | jq '.checks[] | select(.name=="schema_version")'
# => {"name":"schema_version","status":"ok","message":"Version 29 (latest: 29)"}

cd ~/gbrain
git pull origin master         # → ee9ceb3 (v0.27.0)
bun install                    # (postinstall hits chmod issue, see Note)
chmod +x src/cli.ts            # restore exec bit on bin symlink target

gbrain --version               # gbrain 0.27.0
gbrain apply-migrations --yes
# Applies "v0.22.4 frontmatter-guard adoption", then prints:
#   ⚠️  Schema version 29 is behind latest 36.
#   To run them now: gbrain init --migrate-only

gbrain init --migrate-only

Output

  Pre-v0.21 brain detected, applying forward-reference bootstrap
column "provider_id" does not exist

(exit code 1)

Expected

Per the v0.22.6.1 release notes ("No-op on fresh installs and modern brains"), the bootstrap probe should detect schema v29 and skip the pre-v0.21 forward-references, then run the v29 → v36 migration chain.

Actual

Bootstrap mis-classifies a confirmed schema-v29 brain as pre-v0.21 and crashes on what appears to be a v0.27-introduced column (provider_id, presumably from the new AI gateway architecture).

Resolution on our end

Rolled back successfully:

  1. mv ~/.gbrain ~/.gbrain.failed-migration-<date> && mv ~/.gbrain.bak.<date> ~/.gbrain
  2. cd ~/gbrain && git reset --hard 172b55b && chmod +x src/cli.ts && bun install
  3. Brain back at 1788 pages / schema v29 / v0.22.0 binary, fully operational.

The half-migrated brain is preserved locally for diagnostics. It contains personal content so I can't attach it directly, but happy to provide a scrubbed PGLite dump or specific table snapshots (pages, links, migrations ledger, etc.) if that would help narrow this down.

Note: postinstall hook permission failure (probably orthogonal)

After bun install, the postinstall hook (gbrain apply-migrations --yes --non-interactive) hit Permission denied on ~/.bun/bin/gbrain. Root cause: src/cli.ts is committed at mode 100644 upstream but needs 100755 for the bin symlink to execute. A previous postinstall had chmod +x'd it locally; resetting the working tree reverted that. Manual chmod +x src/cli.ts is a workaround. May be worth committing the file at 100755 upstream so the symlink is executable on first install.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions