|
1 | | -# Migration tool for JS IPFS Repo |
| 1 | +# Migration tool for JS IPFS Repo <!-- omit in toc --> |
2 | 2 |
|
3 | 3 | [](https://travis-ci.com/ipfs/js-ipfs-repo-migrations) |
4 | 4 | [](https://codecov.io/gh/ipfs/js-ipfs-repo-migrations) |
|
15 | 15 |
|
16 | 16 | This package is inspired by the [go-ipfs repo migration tool](https://github.com/ipfs/fs-repo-migrations/) |
17 | 17 |
|
18 | | -## Lead Maintainer |
| 18 | +## Lead Maintainer <!-- omit in toc --> |
19 | 19 |
|
20 | 20 | [Adam Uhlíř](https://github.com/auhau/) |
21 | 21 |
|
22 | | -## Table of Contents |
| 22 | +## Table of Contents <!-- omit in toc --> |
23 | 23 |
|
24 | 24 | - [Background](#background) |
25 | 25 | - [Install](#install) |
26 | 26 | - [npm](#npm) |
27 | 27 | - [Use in Node.js](#use-in-nodejs) |
28 | 28 | - [Use in a browser with browserify, webpack or any other bundler](#use-in-a-browser-with-browserify-webpack-or-any-other-bundler) |
29 | | - - [Use in a browser Using a script tag](#use-in-a-browser-using-a-script-tag) |
30 | 29 | - [Usage](#usage) |
31 | 30 | - [API](#api) |
| 31 | + - [`.migrate(path, toVersion, {ignoreLock, repoOptions, onProgress, isDryRun}) -> Promise<void>`](#migratepath-toversion-ignorelock-repooptions-onprogress-isdryrun---promisevoid) |
| 32 | + - [`onProgress(migration, counter, totalMigrations)`](#onprogressmigration-counter-totalmigrations) |
| 33 | + - [`.revert(path, toVersion, {ignoreLock, repoOptions, onProgress, isDryRun}) -> Promise<void>`](#revertpath-toversion-ignorelock-repooptions-onprogress-isdryrun---promisevoid) |
| 34 | + - [`getLatestMigrationVersion() -> int`](#getlatestmigrationversion---int) |
32 | 35 | - [CLI](#cli) |
33 | 36 | - [Creating a new migration](#creating-a-new-migration) |
34 | 37 | - [Architecture of a migration](#architecture-of-a-migration) |
| 38 | + - [`.migrate(repoPath, repoOptions)`](#migraterepopath-repooptions) |
| 39 | + - [`.revert(repoPath, repoOptions)`](#revertrepopath-repooptions) |
35 | 40 | - [Browser vs. NodeJS environments](#browser-vs-nodejs-environments) |
36 | 41 | - [Guidelines](#guidelines) |
37 | 42 | - [Integration with js-ipfs](#integration-with-js-ipfs) |
| 43 | + - [Tests](#tests) |
38 | 44 | - [Empty migrations](#empty-migrations) |
39 | 45 | - [Migrations matrix](#migrations-matrix) |
40 | 46 | - [Developer](#developer) |
41 | | - - [Module versioning notes](#module-versioning-notes) |
| 47 | + - [Module versioning notes](#module-versioning-notes) |
42 | 48 | - [Contribute](#contribute) |
43 | 49 | - [License](#license) |
44 | 50 |
|
45 | 51 | ## Background |
46 | 52 |
|
47 | | - |
48 | 53 | As js-ipfs evolves and new technologies, algorithms and data structures are incorporated it is necessary to |
49 | 54 | enable users to transition between versions. Different versions of js-ipfs may expect a different IPFS repo structure or content (see: [IPFS repo spec](https://github.com/ipfs/specs/tree/master/repo), [JS implementation](https://github.com/ipfs/js-ipfs-repo) ). |
50 | 55 | So the IPFS repo is versioned, and this package provides a framework to create migrations to transition |
@@ -87,10 +92,15 @@ const migrations = require('ipfs-repo-migrations') |
87 | 92 | const repoPath = 'some/repo/path' |
88 | 93 | const currentRepoVersion = 7 |
89 | 94 | const latestVersion = migrations.getLatestMigrationVersion() |
| 95 | +const repoOptions = { |
| 96 | + ... // the same storage backend/storage options passed to `ipfs-repo` |
| 97 | +} |
90 | 98 |
|
91 | 99 | if(currentRepoVersion < latestVersion){ |
92 | 100 | // Old repo! Lets migrate to latest version! |
93 | | - await migrations.migrate(repoPath, latestVersion) |
| 101 | + await migrations.migrate(repoPath, latestVersion, { |
| 102 | + repoOptions |
| 103 | + }) |
94 | 104 | } |
95 | 105 | ``` |
96 | 106 |
|
|
0 commit comments