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>
This commit is contained in:
committed by
Steve Yegge
parent
e74cab8c6d
commit
4e3e9d1441
@@ -33,6 +33,10 @@ Without subcommand, detects and migrates database schema to current version:
|
||||
- Updates schema version metadata
|
||||
- Removes stale databases (with confirmation)
|
||||
|
||||
Backend migration flags:
|
||||
--to-dolt Migrate from SQLite to Dolt backend
|
||||
--to-sqlite Migrate from Dolt to SQLite backend (escape hatch)
|
||||
|
||||
Subcommands:
|
||||
hash-ids Migrate sequential IDs to hash-based IDs (legacy)
|
||||
issues Move issues between repositories
|
||||
@@ -62,6 +66,20 @@ Subcommands:
|
||||
return
|
||||
}
|
||||
|
||||
// Handle --to-dolt flag (SQLite to Dolt migration)
|
||||
toDolt, _ := cmd.Flags().GetBool("to-dolt")
|
||||
if toDolt {
|
||||
handleToDoltMigration(dryRun, autoYes)
|
||||
return
|
||||
}
|
||||
|
||||
// Handle --to-sqlite flag (Dolt to SQLite migration, escape hatch)
|
||||
toSQLite, _ := cmd.Flags().GetBool("to-sqlite")
|
||||
if toSQLite {
|
||||
handleToSQLiteMigration(dryRun, autoYes)
|
||||
return
|
||||
}
|
||||
|
||||
// Find .beads directory
|
||||
beadsDir := beads.FindBeadsDir()
|
||||
if beadsDir == "" {
|
||||
@@ -974,6 +992,8 @@ func init() {
|
||||
migrateCmd.Flags().Bool("dry-run", false, "Show what would be done without making changes")
|
||||
migrateCmd.Flags().Bool("update-repo-id", false, "Update repository ID (use after changing git remote)")
|
||||
migrateCmd.Flags().Bool("inspect", false, "Show migration plan and database state for AI agent analysis")
|
||||
migrateCmd.Flags().Bool("to-dolt", false, "Migrate from SQLite to Dolt backend")
|
||||
migrateCmd.Flags().Bool("to-sqlite", false, "Migrate from Dolt to SQLite backend (escape hatch)")
|
||||
migrateCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output migration statistics in JSON format")
|
||||
rootCmd.AddCommand(migrateCmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user