fix(schema): repair migration-state drift that breaks v53 upgrades (#4502, #4534) (#4538)

* fix(schema): repair migration-state drift that breaks v53 upgrades (#4502, #4534)

Two field reports against v1.1.0-rc.1 show real databases reaching the v53
migration with state the migration lineage assumes cannot exist:

- #4502: the rig/agent columns (hook_bead, role_bead, agent_state,
  last_activity, role_type, rig) were only ever added to the squashed
  bootstrap 0001_create_issues, so a database bootstrapped before they
  existed sits at schema v52 without them. Migration 0053 copies exactly
  those columns from wisps into issues and failed with Unknown column
  even with zero rig wisps to repair. 0053 now ensures each of the six
  exists on issues before the copy (databases in the wild may have some
  but not all).

- #4534: migration 0039 dropped fk_counter_parent and clone-local
  migration 0002 re-added it under FOREIGN_KEY_CHECKS=0, so a
  child_counters row orphaned during the FK-less window survives the
  constraint's return, and Dolt constraint validation then rejects
  subsequent inserts on an otherwise healthy database. New clone-local
  migration 0011 moves live-wisp counters to wisp_child_counters and
  deletes rows dangling from issues - the rows ON DELETE CASCADE would
  have removed had the FK been in force. Already-bitten databases heal
  on the next command with the new binary.

Verified end-to-end with real binaries: a stock rc.1 bd fails on a
v52-shaped embedded database with 'Unknown column agent_state in
issues'; the patched bd migrates it, restores the columns, promotes rig
wisps, and records v53. On a database with a planted orphaned counter
row, the patched bd applies ignored 0011 on open, removes the orphan,
and preserves live counters.

Docs ride along because they close the same exposure: the upgrade guide
recipes now start with a JSONL export before migrating, and the README
gains an upgrading pointer (it previously never mentioned upgrades).

Fix shapes suggested by the reporters' field repair notes: gojun077
(#4502) validated the guarded ALTERs manually, eitsupi (#4534) isolated
the orphaned-row root cause and confirmed deletion as the cure.

Agent-Signature: claude-fable-5-high on behalf of matt wilkie
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0167xsjJDukVKE7BE1i4W2wE

* fixup: move 0053 drift repair from SQL into the migration runner

The migration hygiene gate (check C) rightly freezes shipped migration
files: editing one forks fresh clones from upgraded clones via the
recorded content hash. But a migration that FAILS on drifted databases
cannot be fixed forward with a new file either - the failing version
aborts the pass before any later version runs. Repair the drift in Go
immediately before applying v53 instead (precedent:
ensureContentHashColumn), leaving 0053's content untouched.

Re-validated end-to-end: stock rc.1 still fails on the v52-shaped
embedded database; the reworked binary opens it, restores all six
columns, records v53, data intact.

Agent-Signature: claude-fable-5-high on behalf of matt wilkie
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0167xsjJDukVKE7BE1i4W2wE

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
matt wilkie 2026-07-01 23:45:57 -07:00 • committed by GitHub
commit 5589e3f6d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 379 additions and 5 deletions

View file

@ -7,6 +7,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Upgrade Notes
- **Back up before migrating.** The upgrade guide's remote-backed recipes now
start with a JSONL export (`bd export --all -o ...`) before
`BD_ALLOW_REMOTE_MIGRATE=1 bd migrate`. The two fixes below repair real
databases that reached a migration with drifted state; an export is the
cheap insurance while such drift is being repaired.
### Fixed
- **v53 migration no longer fails on pre-rig `issues` tables.** The rig/agent
columns (`hook_bead`, `role_bead`, `agent_state`, `last_activity`,
`role_type`, `rig`) were only ever added to the squashed bootstrap
`0001_create_issues`, so a database bootstrapped before they existed sits at
schema v52 without them — and migration 0053, which copies those columns
from `wisps`, failed with `Unknown column 'agent_state' in 'issues'` even
with zero rig wisps to repair
([#4502](https://github.com/gastownhall/beads/issues/4502)). The migration
runner now repairs the drift in code immediately before applying v53,
adding whichever of the six columns are missing (databases in the wild may
have some but not all). Shipped migration files stay frozen — the repair
lives in the runner because a failing migration can never be fixed forward
by a later migration file.
- **One orphaned `child_counters` row no longer bricks every `bd create`.**
Migration 0039 dropped `fk_counter_parent` and clone-local migration 0002
re-added it under `FOREIGN_KEY_CHECKS = 0`, so a counter row orphaned during
the FK-less window (an interrupted create, a parent deleted without cascade)
survived the constraint's return — and Dolt then failed constraint
validation on every subsequent insert, including brand-new top-level issues,
on an otherwise healthy database
([#4534](https://github.com/gastownhall/beads/issues/4534)). A new
clone-local migration moves any live-wisp counters to `wisp_child_counters`
and deletes rows dangling from `issues` — the same rows the FK's
`ON DELETE CASCADE` would have removed had it been in force. Runs
automatically on the next command with the new binary; already-bitten
databases are healed in place.
## [1.1.0-rc.1] - 2026-06-23
### Upgrade Notes

View file

@ -94,6 +94,12 @@ npm install -g @beads/bd # Node.js users
**Requirements:** macOS, Linux, Windows, or FreeBSD. See [docs/INSTALLING.md](docs/INSTALLING.md) for complete installation guide.
**Upgrading?** Replacing the binary is not always the whole story: releases can
carry schema migrations, and a database that syncs to a Dolt remote must be
migrated by exactly one designated clone. Back up first (`bd export --all`),
then follow the [upgrade guide](https://gastownhall.github.io/beads/docs/getting-started/upgrading)
(also summarized in [docs/INSTALLING.md](docs/INSTALLING.md#updating-bd)).
### Security And Verification
Before trusting any downloaded binary, verify its checksum against the release `checksums.txt`.

View file

@ -211,6 +211,131 @@ func TestMigration0053PromotesRigWisps(t *testing.T) {
`SELECT COUNT(*) FROM wisp_dependencies WHERE issue_id = ?`, 0, rigID)
}
// TestMigration0053RepairsIssuesMissingRigColumns reproduces #4502: a database
// whose schema_migrations sits at v52 but whose issues table was bootstrapped
// before the rig/agent columns existed in 0001_create_issues. The 0053 rig
// repair copies those columns from wisps, so it must ensure they exist on
// issues first instead of failing with "Unknown column".
func TestMigration0053RepairsIssuesMissingRigColumns(t *testing.T) {
store, cleanup := setupTestStore(t)
defer cleanup()
ctx, cancel := testContext(t)
defer cancel()
// Simulate the pre-rig issues shape. Databases in the wild can be
// missing any subset; drop all six to cover the worst case.
for _, col := range []string{"hook_bead", "role_bead", "agent_state", "last_activity", "role_type", "rig"} {
if _, err := store.db.ExecContext(ctx, "ALTER TABLE issues DROP COLUMN "+col); err != nil {
t.Fatalf("drop issues.%s: %v", col, err)
}
}
const rigID = "schema-rig-legacy"
if _, err := store.db.ExecContext(ctx, `
INSERT INTO wisps (id, title, description, design, acceptance_criteria, notes, status, priority, issue_type, ephemeral, agent_state, rig)
VALUES (?, 'Rig identity', '', '', '', '', 'open', 1, 'rig', 1, 'ready', 'test-rig')
`, rigID); err != nil {
t.Fatalf("seed rig wisp: %v", err)
}
if _, err := store.db.ExecContext(ctx, "CALL DOLT_ADD('-A')"); err != nil {
t.Fatalf("stage legacy fixture: %v", err)
}
if _, err := store.db.ExecContext(ctx, "CALL DOLT_COMMIT('-m', 'seed legacy issues shape')"); err != nil &&
!strings.Contains(strings.ToLower(err.Error()), "nothing to commit") {
t.Fatalf("commit legacy fixture: %v", err)
}
if _, err := store.db.ExecContext(ctx, "DELETE FROM schema_migrations WHERE version = ?", schema.LatestVersion()); err != nil {
t.Fatalf("mark 0053 pending: %v", err)
}
if _, err := schema.MigrateUp(ctx, store.db); err != nil {
t.Fatalf("MigrateUp on legacy issues shape: %v", err)
}
var promoted int
if err := store.db.QueryRowContext(ctx,
`SELECT COUNT(*) FROM issues WHERE id = ? AND issue_type = 'rig' AND ephemeral = 0 AND agent_state = 'ready' AND rig = 'test-rig'`,
rigID).Scan(&promoted); err != nil {
t.Fatalf("count promoted rig issue: %v", err)
}
if promoted != 1 {
t.Fatalf("promoted rig issue rows = %d, want 1 with rig columns restored and copied", promoted)
}
}
// TestIgnoredMigration0011CleansOrphanedChildCounters reproduces #4534: a
// child_counters row orphaned while fk_counter_parent was dropped (0039)
// survives the FK's re-add (ignored 0002 runs under FOREIGN_KEY_CHECKS=0),
// and the dangling row then fails constraint validation on every subsequent
// write. The cleanup migration must delete orphans and keep live counters.
func TestIgnoredMigration0011CleansOrphanedChildCounters(t *testing.T) {
store, cleanup := setupTestStore(t)
defer cleanup()
ctx, cancel := testContext(t)
defer cancel()
const parentID = "schema-counter-parent"
if _, err := store.db.ExecContext(ctx, `
INSERT INTO issues (id, title, description, design, acceptance_criteria, notes, status, priority, issue_type)
VALUES (?, 'parent', '', '', '', '', 'open', 2, 'task')
`, parentID); err != nil {
t.Fatalf("seed parent issue: %v", err)
}
// MaxOpenConns is 1, so the session FK toggle holds for the next insert.
if _, err := store.db.ExecContext(ctx, "SET FOREIGN_KEY_CHECKS = 0"); err != nil {
t.Fatalf("disable fk checks: %v", err)
}
if _, err := store.db.ExecContext(ctx,
`INSERT INTO child_counters (parent_id, last_child) VALUES ('schema-counter-orphan', 3), (?, 5)`,
parentID); err != nil {
t.Fatalf("seed counters with legacy orphan: %v", err)
}
if _, err := store.db.ExecContext(ctx, "SET FOREIGN_KEY_CHECKS = 1"); err != nil {
t.Fatalf("re-enable fk checks: %v", err)
}
if _, err := store.db.ExecContext(ctx, "CALL DOLT_ADD('-A')"); err != nil {
t.Fatalf("stage counter fixture: %v", err)
}
if _, err := store.db.ExecContext(ctx, "CALL DOLT_COMMIT('-m', 'seed orphaned child counter')"); err != nil &&
!strings.Contains(strings.ToLower(err.Error()), "nothing to commit") {
t.Fatalf("commit counter fixture: %v", err)
}
if _, err := store.db.ExecContext(ctx, "DELETE FROM ignored_schema_migrations WHERE version = ?", schema.LatestIgnoredVersion()); err != nil {
t.Fatalf("mark ignored 0011 pending: %v", err)
}
if _, err := schema.MigrateUp(ctx, store.db); err != nil {
t.Fatalf("MigrateUp with orphaned child counter: %v", err)
}
assertCount := func(name, query string, want int, args ...any) {
t.Helper()
var got int
if err := store.db.QueryRowContext(ctx, query, args...).Scan(&got); err != nil {
t.Fatalf("%s: %v", name, err)
}
if got != want {
t.Fatalf("%s = %d, want %d", name, got, want)
}
}
assertCount("orphaned counter rows",
`SELECT COUNT(*) FROM child_counters WHERE parent_id = 'schema-counter-orphan'`, 0)
assertCount("live counter rows",
`SELECT COUNT(*) FROM child_counters WHERE parent_id = ? AND last_child = 5`, 1, parentID)
// The #4534 symptom: with the orphan gone, plain issue inserts work again.
if _, err := store.db.ExecContext(ctx, `
INSERT INTO issues (id, title, description, design, acceptance_criteria, notes, status, priority, issue_type)
VALUES ('schema-counter-after', 'insert works again', '', '', '', '', 'open', 2, 'task')
`); err != nil {
t.Fatalf("insert after cleanup: %v", err)
}
}
// TestSchemaRunsInitWhenMissing verifies that initSchemaOnDB runs
// full initialization when schema_migrations doesn't exist (fresh db).
func TestSchemaRunsInitWhenMissing(t *testing.T) {

View file

@ -115,6 +115,15 @@ func expectOnePendingMigration(t *testing.T, mock sqlmock.Sqlmock) {
WillReturnResult(sqlmock.NewResult(0, 0))
expectContentHashColumnExists(mock)
expectScalar(mock, "SELECT COALESCE(MAX(version), 0) FROM schema_migrations", "version", latest-1)
if latest == 53 {
// The v53 pre-repair (#4502) probes the six rig/agent columns on
// issues; this mocked world has them all, so no ALTERs follow.
for _, col := range []string{"hook_bead", "role_bead", "agent_state", "last_activity", "role_type", "rig"} {
mock.ExpectQuery(`SELECT COUNT\(\*\) FROM INFORMATION_SCHEMA\.COLUMNS`).
WithArgs(col).
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(1))
}
}
mock.ExpectExec("(?s).*").
WillReturnResult(sqlmock.NewResult(0, 0))
mock.ExpectExec(regexp.QuoteMeta("INSERT IGNORE INTO schema_migrations (version, content_hash) VALUES (?, ?)")).

View file

@ -0,0 +1,58 @@
package schema
import (
"context"
"fmt"
)
// Pre-migration repairs run immediately before a specific pending migration
// file is applied. Shipped migration files are frozen (see
// scripts/check-migration-hygiene.sh): editing one forks fresh clones from
// upgraded clones via the recorded content hash, and a bug that makes a
// migration FAIL on drifted databases cannot be fixed forward with a new
// migration either — the failing file aborts the pass before any later
// version runs. Repairing the drift in code, keyed to the pending version,
// is the only path that heals affected databases without touching shipped
// SQL. Precedent: ensureContentHashColumn, the aux row-id backfill.
// preMigrationRepair dispatches any repair registered for (source, version).
func (m migrationSource) preMigrationRepair(ctx context.Context, db DBConn, version int) error {
if m.cursorTable == "schema_migrations" && version == 53 {
return ensureIssuesRigColumns(ctx, db)
}
return nil
}
// ensureIssuesRigColumns repairs #4502: the rig/agent columns were only ever
// added to the squashed bootstrap 0001_create_issues, so a database
// bootstrapped before they existed reaches schema v52 without them, and
// migration 0053 — which copies exactly these columns from wisps into
// issues — fails with "Unknown column" even with zero rig wisps to repair.
// Databases in the wild may have some but not all six, so each is checked
// individually. Definitions mirror the current bootstrap schema.
func ensureIssuesRigColumns(ctx context.Context, db DBConn) error {
columns := []struct{ name, definition string }{
{"hook_bead", "VARCHAR(255) DEFAULT ''"},
{"role_bead", "VARCHAR(255) DEFAULT ''"},
{"agent_state", "VARCHAR(32) DEFAULT ''"},
{"last_activity", "DATETIME"},
{"role_type", "VARCHAR(32) DEFAULT ''"},
{"rig", "VARCHAR(255) DEFAULT ''"},
}
for _, col := range columns {
var present int
if err := db.QueryRowContext(ctx, `
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'issues' AND COLUMN_NAME = ?
`, col.name).Scan(&present); err != nil {
return fmt.Errorf("checking issues.%s: %w", col.name, err)
}
if present > 0 {
continue
}
if _, err := db.ExecContext(ctx, "ALTER TABLE issues ADD COLUMN "+col.name+" "+col.definition); err != nil {
return fmt.Errorf("adding issues.%s for migration 0053: %w", col.name, err)
}
}
return nil
}

View file

@ -0,0 +1,53 @@
-- Clean up child_counters rows whose parent row no longer exists (#4534).
--
-- Migration 0039 dropped fk_counter_parent and ignored migration 0002
-- re-added it under FOREIGN_KEY_CHECKS = 0, so counter rows orphaned during
-- the FK-less window (a create that incremented the counter but rolled back
-- before inserting the child, or a parent deleted with no cascade) survive
-- the constraint's return. Dolt then fails constraint validation on
-- subsequent writes, so one legacy orphan bricks every bd create on an
-- otherwise healthy database.
--
-- First move counters that belong to live wisps into wisp_child_counters
-- (same semantics as ignored migration 0002, kept idempotent), then delete
-- rows dangling from issues — exactly what the FK's ON DELETE CASCADE would
-- have done had it been in force when the parent went away.
SET @has_child_counters = (
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'child_counters'
);
SET @has_wisps = (
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'wisps'
);
SET @has_wisp_child_counters = (
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'wisp_child_counters'
);
SET @sql = IF(@has_child_counters > 0 AND @has_wisps > 0 AND @has_wisp_child_counters > 0,
'INSERT IGNORE INTO wisp_child_counters (parent_id, last_child) SELECT cc.parent_id, cc.last_child FROM child_counters cc INNER JOIN wisps w ON w.id = cc.parent_id',
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = IF(@has_child_counters > 0 AND @has_wisps > 0 AND @has_wisp_child_counters > 0,
'UPDATE wisp_child_counters wcc JOIN child_counters cc ON cc.parent_id = wcc.parent_id JOIN wisps w ON w.id = cc.parent_id SET wcc.last_child = GREATEST(wcc.last_child, cc.last_child)',
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = IF(@has_child_counters > 0 AND @has_wisps > 0 AND @has_wisp_child_counters > 0,
'DELETE cc FROM child_counters cc INNER JOIN wisps w ON w.id = cc.parent_id',
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = IF(@has_child_counters > 0,
'DELETE cc FROM child_counters cc LEFT JOIN issues i ON i.id = cc.parent_id WHERE i.id IS NULL',
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

View file

@ -942,6 +942,9 @@ func (m migrationSource) migrate(ctx context.Context, db DBConn, upTo int) (int,
if err != nil {
return count, columnAdded, fmt.Errorf("reading migration %s: %w", mf.name, err)
}
if err := m.preMigrationRepair(ctx, db, mf.version); err != nil {
return count, columnAdded, fmt.Errorf("pre-repair for migration %s: %w", mf.name, err)
}
if _, err := db.ExecContext(ctx, string(data)); err != nil {
return count, columnAdded, fmt.Errorf("migration %s: %w", mf.name, err)
}

View file

@ -216,6 +216,73 @@ func TestMigration0053RepairsRigWispsShape(t *testing.T) {
}
}
func TestEnsureIssuesRigColumnsAddsOnlyMissing(t *testing.T) {
db, mock, err := sqlmock.New()
if err != nil {
t.Fatalf("sqlmock.New: %v", err)
}
defer db.Close()
// #4502: issues tables bootstrapped before the rig/agent columns landed
// in 0001 reach v52 without them; the 0053 pre-repair must add exactly
// the missing ones. Simulate hook_bead present, the other five absent.
countQuery := `SELECT COUNT\(\*\) FROM INFORMATION_SCHEMA\.COLUMNS`
mock.ExpectQuery(countQuery).WithArgs("hook_bead").
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(1))
for _, col := range []struct{ name, ddl string }{
{"role_bead", "ALTER TABLE issues ADD COLUMN role_bead VARCHAR\\(255\\) DEFAULT ''"},
{"agent_state", "ALTER TABLE issues ADD COLUMN agent_state VARCHAR\\(32\\) DEFAULT ''"},
{"last_activity", "ALTER TABLE issues ADD COLUMN last_activity DATETIME"},
{"role_type", "ALTER TABLE issues ADD COLUMN role_type VARCHAR\\(32\\) DEFAULT ''"},
{"rig", "ALTER TABLE issues ADD COLUMN rig VARCHAR\\(255\\) DEFAULT ''"},
} {
mock.ExpectQuery(countQuery).WithArgs(col.name).
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(0))
mock.ExpectExec(col.ddl).WillReturnResult(sqlmock.NewResult(0, 0))
}
if err := ensureIssuesRigColumns(context.Background(), db); err != nil {
t.Fatalf("ensureIssuesRigColumns: %v", err)
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Fatalf("unmet sql expectations: %v", err)
}
}
func TestPreMigrationRepairScopedToMain0053(t *testing.T) {
// The repair must not fire for other versions or for the ignored source
// (whose cursor table differs); nil DB proves no queries are attempted.
if err := mainSource.preMigrationRepair(context.Background(), nil, 52); err != nil {
t.Fatalf("main v52 repair = %v, want nil no-op", err)
}
if err := ignoredSource.preMigrationRepair(context.Background(), nil, 53); err != nil {
t.Fatalf("ignored v53 repair = %v, want nil no-op", err)
}
}
func TestIgnoredMigration0011CleansOrphanedChildCountersShape(t *testing.T) {
sql, err := os.ReadFile("migrations/ignored/0011_cleanup_orphaned_child_counters.up.sql")
if err != nil {
t.Fatalf("read ignored 0011 up migration: %v", err)
}
// #4534: counter rows orphaned while fk_counter_parent was dropped brick
// all inserts once the FK returns; the cleanup must preserve live-wisp
// counters and delete only rows dangling from issues.
body := string(sql)
for _, want := range []string{
"@has_child_counters",
"INSERT IGNORE INTO wisp_child_counters",
"GREATEST(wcc.last_child, cc.last_child)",
"DELETE cc FROM child_counters cc INNER JOIN wisps w ON w.id = cc.parent_id",
"DELETE cc FROM child_counters cc LEFT JOIN issues i ON i.id = cc.parent_id WHERE i.id IS NULL",
} {
if !strings.Contains(body, want) {
t.Fatalf("ignored 0011 migration missing cleanup marker %q", want)
}
}
}
func TestMigration0053NoopsWithoutWispTablesThroughDoltCLI(t *testing.T) {
testutil.RequireDoltBinary(t)

View file

@ -140,14 +140,28 @@ pending migrations is gated on **every** open — `bd dolt push` and `bd dolt
pull` are refused too, not just `bd migrate`. So do all syncing with your
**current** binary, *before* you install the new one.
**Back up before you migrate.** Schema migrations assume the database matches
the shape the previous migrations left behind; real databases sometimes drift
(interrupted writes, tooling bugs, very old bootstraps). A JSONL export is
cheap, issue-complete, and importable by any bd version:
```bash
bd export --all -o .beads/backup/pre-migrate-$(date +%Y%m%d).jsonl
```
`bd export` captures issues, not Dolt history or config — for a full snapshot
also copy the `.beads` directory (or `dolt backup` in server mode) while no
`bd` command is running.
**Single clone (including a solo user with a remote):**
```bash
bd dolt push # 1. CURRENT binary: publish all local work
# 2. install the new binary (see Upgrading above)
BD_ALLOW_REMOTE_MIGRATE=1 bd migrate # 3. migrate as the designated migrator
bd dolt push # 4. publish the migrated schema
bd version # 5. confirm the new version is active
bd export --all -o .beads/backup/pre-migrate.jsonl # 2. backup (see above)
# 3. install the new binary (see Upgrading above)
BD_ALLOW_REMOTE_MIGRATE=1 bd migrate # 4. migrate as the designated migrator
bd dolt push # 5. publish the migrated schema
bd version # 6. confirm the new version is active
```
**Multiple clones sharing one remote:**
@ -158,7 +172,9 @@ bd version # 5. confirm the new version is active
bd dolt push
bd dolt pull
# 2. Designated migrator ONLY: install the new binary, then migrate and publish.
# 2. Designated migrator ONLY: back up, install the new binary, then migrate
# and publish.
bd export --all -o .beads/backup/pre-migrate.jsonl
BD_ALLOW_REMOTE_MIGRATE=1 bd migrate
bd dolt push