| 1 | // Package main implements fs-repo-17-to-18 migration for IPFS repositories. |
| 2 | // |
| 3 | // This migration consolidates the Provider and Reprovider configurations into |
| 4 | // a unified Provide configuration section. |
| 5 | // |
| 6 | // Changes made: |
| 7 | // - Migrates Provider.Enabled to Provide.Enabled |
| 8 | // - Migrates Provider.WorkerCount to Provide.DHT.MaxWorkers |
| 9 | // - Migrates Reprovider.Strategy to Provide.Strategy (converts "flat" to "all") |
| 10 | // - Migrates Reprovider.Interval to Provide.DHT.Interval |
| 11 | // - Removes deprecated Provider and Reprovider sections |
| 12 | // |
| 13 | // The migration is reversible and creates config.17-to-18.bak for rollback. |
| 14 | // |
| 15 | // Usage: |
| 16 | // |
| 17 | // fs-repo-17-to-18 -path /path/to/ipfs/repo [-verbose] [-revert] |
| 18 | // |
| 19 | // This migration is embedded in Kubo and runs automatically during daemon startup. |
| 20 | // This standalone binary is provided for manual migration scenarios. |
| 21 | package main |
| 22 | |
| 23 | import ( |
| 24 | "flag" |
| 25 | "fmt" |
| 26 | "os" |
| 27 | |
| 28 | "github.com/ipfs/kubo/repo/fsrepo/migrations/common" |
| 29 | mg17 "github.com/ipfs/kubo/repo/fsrepo/migrations/fs-repo-17-to-18/migration" |
| 30 | ) |
| 31 | |
| 32 | func main() { |
| 33 | var path = flag.String("path", "", "Path to IPFS repository") |
| 34 | var verbose = flag.Bool("verbose", false, "Enable verbose output") |
| 35 | var revert = flag.Bool("revert", false, "Revert migration") |
| 36 | flag.Parse() |
| 37 | |
| 38 | if *path == "" { |
| 39 | fmt.Fprintf(os.Stderr, "Error: -path flag is required\n") |
| 40 | flag.Usage() |
| 41 | os.Exit(1) |
| 42 | } |
| 43 | |
| 44 | opts := common.Options{ |
| 45 | Path: *path, |
| 46 | Verbose: *verbose, |
| 47 | } |
| 48 | |
| 49 | var err error |
| 50 | if *revert { |
| 51 | err = mg17.Migration.Revert(opts) |
| 52 | } else { |
| 53 | err = mg17.Migration.Apply(opts) |
| 54 | } |
| 55 | |
| 56 | if err != nil { |
| 57 | fmt.Fprintf(os.Stderr, "Migration failed: %v\n", err) |
| 58 | os.Exit(1) |
| 59 | } |
| 60 | } |