Files
beads/cmd/bd/migrate_dolt_nocgo.go
beads/crew/jane 4e3e9d1441 feat(migrate): add SQLite to Dolt migration tooling (hq-ew1mbr.6)
Add `bd migrate --to-dolt` and `bd migrate --to-sqlite` commands for
migrating between SQLite and Dolt storage backends.

Features:
- `--to-dolt`: Migrate from SQLite to Dolt backend
  - Creates backup of SQLite database before migration
  - Imports all issues, labels, and dependencies
  - Updates metadata.json to use Dolt backend
  - Preserves JSONL export configuration

- `--to-sqlite`: Escape hatch to migrate back to SQLite
  - Exports all data from Dolt to new SQLite database
  - Updates metadata.json to use SQLite backend

Both commands support:
- `--dry-run` flag to preview changes
- `--yes` flag for automated/scripted usage
- `--json` flag for machine-readable output
- Non-cgo stub for builds without CGO support

This implements Part 7 (Migration Tooling) of DOLT-STORAGE-DESIGN.md.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:46:15 -08:00

41 lines
1.2 KiB
Go

//go:build !cgo
package main
import (
"fmt"
"os"
)
// handleToDoltMigration is a stub for non-cgo builds.
// Dolt requires CGO, so this migration is not available.
func handleToDoltMigration(dryRun bool, autoYes bool) {
if jsonOutput {
outputJSON(map[string]interface{}{
"error": "dolt_not_available",
"message": "Dolt backend requires CGO. This binary was built without CGO support.",
})
} else {
fmt.Fprintf(os.Stderr, "Error: Dolt backend requires CGO\n")
fmt.Fprintf(os.Stderr, "This binary was built without CGO support.\n")
fmt.Fprintf(os.Stderr, "To use Dolt, rebuild with: CGO_ENABLED=1 go build\n")
}
os.Exit(1)
}
// handleToSQLiteMigration is a stub for non-cgo builds.
// Dolt requires CGO, so this migration from Dolt is not available.
func handleToSQLiteMigration(dryRun bool, autoYes bool) {
if jsonOutput {
outputJSON(map[string]interface{}{
"error": "dolt_not_available",
"message": "Dolt backend requires CGO. This binary was built without CGO support.",
})
} else {
fmt.Fprintf(os.Stderr, "Error: Dolt backend requires CGO\n")
fmt.Fprintf(os.Stderr, "This binary was built without CGO support.\n")
fmt.Fprintf(os.Stderr, "To use Dolt, rebuild with: CGO_ENABLED=1 go build\n")
}
os.Exit(1)
}