beads/cmd/bd/migrate_dolt_cmd.go
beads/crew/emma 2137693dad revert: restore embedded Dolt mode (was only supposed to be removed from Gas Town)
Revert commits e5330641 and 0df41523 which removed embedded Dolt mode
from the beads codebase. The embedded Dolt removal was only intended for
Gas Town, not for Beads.

Restores:
- dolthub/driver dependency and embedded connection path
- Advisory flock (AccessLock) for concurrent process protection
- Embedded connector lifecycle management in DoltStore
- All CGO build tags across ~45 files
- Vendored go-icu-regex library
- nocgo stub files for non-CGO builds
- Bootstrap and embedded_uow helpers
- factory_dolt_test.go and dolt_singleprocess_test.go

Merge conflict resolutions:
- store.go: TCP fail-fast check wrapped inside if cfg.ServerMode
- store.go: backtick-quoting for embedded CREATE DATABASE (prefix-based names)
- perf_dolt.go: port references updated from 3306 to 3307
- ci.yml: restored continue-on-error for Nix (dolthub/driver requires Go 1.25.6+)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-07 21:21:24 -08:00

44 lines
1.3 KiB
Go

//go:build cgo
package main
import (
"github.com/spf13/cobra"
)
var migrateDoltCmd = &cobra.Command{
Use: "dolt",
Short: "Migrate from SQLite to Dolt backend",
Long: `Migrate the current beads installation from SQLite to Dolt backend.
This command:
1. Creates a backup of the SQLite database
2. Creates a Dolt database in .beads/dolt/
3. Imports all issues, labels, dependencies, and events
4. Copies all config values
5. Updates metadata.json to use Dolt backend
The original SQLite database is preserved (can be deleted after verification).
Examples:
bd migrate dolt # Interactive migration with confirmation
bd migrate dolt --dry-run # Preview what would happen
bd migrate dolt --yes # Non-interactive (for automation)`,
Run: func(cmd *cobra.Command, args []string) {
dryRun, _ := cmd.Flags().GetBool("dry-run")
autoYes, _ := cmd.Flags().GetBool("yes")
// Block writes in readonly mode (migration modifies data)
if !dryRun {
CheckReadonly("migrate dolt")
}
handleToDoltMigration(dryRun, autoYes)
},
}
func init() {
migrateDoltCmd.Flags().Bool("dry-run", false, "Preview migration without making changes")
migrateDoltCmd.Flags().BoolP("yes", "y", false, "Skip confirmation prompt (for automation)")
migrateCmd.AddCommand(migrateDoltCmd)
}