You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2021. It is now read-only.
Executes a forward migration to a specific version, or to the latest version if a specific version is not specified.
98
98
99
99
**Arguments:**
100
100
101
101
*`path` (string, mandatory) - path to the repo to be migrated
102
+
*`toVersion` (int, mandatory) - version to which the repo should be migrated.
102
103
*`options` (object, optional) - options for the migration
103
-
*`options.toVersion` (int, optional) - version to which the repo should be migrated. Defaults to the latest migration version.
104
104
*`options.ignoreLock` (bool, optional) - if true will not lock the repo when applying migrations. Use with caution.
105
105
*`options.repoOptions` (object, optional) - options that are passed to migrations, that use them to construct the datastore. (options are the same as for IPFSRepo).
106
106
*`options.onProgress` (function, optional) - callback that is called after finishing execution of each migration to report progress.
@@ -115,7 +115,7 @@ Signature of the progress callback.
115
115
*`counter` (int) - index of current migration.
116
116
*`totalMigrations` (int) - total count of migrations that will be run.
Executes backward migration to a specific version.
121
121
@@ -125,7 +125,7 @@ Executes backward migration to a specific version.
125
125
*`toVersion` (int, mandatory) - version to which the repo should be reverted to.
126
126
*`options` (object, optional) - options for the reversion
127
127
*`options.ignoreLock` (bool, optional) - if true will not lock the repo when applying migrations. Use with caution.
128
-
*`options.options` (object, optional) - options that are passed to migrations, that use them to construct the datastore. (options are the same as for IPFSRepo).
128
+
*`options.repoOptions` (object, optional) - options that are passed to migrations, that use them to construct the datastore. (options are the same as for IPFSRepo).
129
129
*`options.onProgress` (function, optional) - callback that is called after finishing execution of each migration to report progress.
130
130
*`options.isDryRun` (bool, optional) - flag that indicates if it is a dry run that should give the same output as running a migration but without making any actual changes.
131
131
@@ -168,33 +168,40 @@ every run of `jsipfs-migrations add` (manual changes should follow the same styl
168
168
169
169
Each migration must follow this API. It must export an object in its `index.js` that has following properties:
170
170
171
-
*`version` (int) - Number that represents the version which the repo will migrate to (eg. `migration-8` will move the repo to version 8).
171
+
*`version` (int) - Number that represents the version which the repo will migrate to (eg. `8` will move the repo to version 8).
172
172
*`description` (string) - Brief description of what the migrations does.
173
173
*`migrate` (function) - Function that performs the migration (see signature of this function below)
174
174
*`revert` (function) - If defined then this function will revert the migration to the previous version. Otherwise it is assumed that it is not possible to revert this migration.
175
175
176
-
#### `.migrate(repoPath, isBrowser)`
176
+
#### `.migrate(repoPath, repoOptions)`
177
177
178
178
_Do not confuse this function with the `require('ipfs-repo-migrations').migrate()` function that drives the whole migration process!_
179
179
180
180
Arguments:
181
181
*`repoPath` (string) - absolute path to the root of the repo
182
-
*`options` (object, optional) - object containing `IPFSRepo` options, that should be used to construct a datastore instance.
183
-
*`isBrowser` (bool) - indicates if the migration is run in a browser environment (as opposed to NodeJS)
182
+
*`repoOptions` (object, optional) - object containing `IPFSRepo` options, that should be used to construct a datastore instance.
184
183
185
-
#### `.revert(repoPath, isBrowser)`
184
+
#### `.revert(repoPath, repoOptions)`
186
185
187
186
_Do not confuse this function with the `require('ipfs-repo-migrations').revert()` function that drives the whole backward migration process!_
188
187
189
188
Arguments:
190
189
*`repoPath` (string) - path to the root of the repo
191
-
*`options` (object, optional) - object containing `IPFSRepo` options, that should be used to construct the datastore instance.
192
-
*`isBrowser` (bool) - indicates if the migration is run in a browser environment (as opposed to NodeJS)
190
+
*`repoOptions` (object, optional) - object containing `IPFSRepo` options, that should be used to construct the datastore instance.
193
191
194
192
### Browser vs. NodeJS environments
195
193
196
-
The migration might need to distinguish in which environment it runs (browser vs. NodeJS). For this reason there is an argument
197
-
`isBrowser` passed to migrations functions. But with simple migrations it should not be necessary to distinguish between
194
+
The migration might need to perform specific tasks in browser or NodeJS environment. In such a case create
195
+
migration file `/migrations/migration-<number>/index_browser.js` which have to follow the same API is described before.
196
+
Then add entry in `package.json` to the `browser` field as follow:
In browser environments then `index.js` will be replaced with `index_browser.js`.
203
+
204
+
Simple migrations should not need to distinguish between
198
205
these environments as the datastore implementation will handle the main differences.
199
206
200
207
There are currently two main datastore implementations:
@@ -221,8 +228,8 @@ write the rest of the migration!
221
228
222
229
### Integration with js-ipfs
223
230
224
-
When a new migration is created, the repo version in [`js-ipfs-repo`](https://github.com/ipfs/js-ipfs-repo)should be updated with the new version,
225
-
together with updated version of this package. Then the updated version should be propagated to `js-ipfs`.
231
+
When a new migration is created, new version of this package have to be released. Afterwards version of this package in [`js-ipfs-repo`](https://github.com/ipfs/js-ipfs-repo)have to be updated
232
+
together with the repo version that `IPFSRepo` expects. Then the updated version of `js-ipfs-repo` should be propagated to `js-ipfs`.
226
233
227
234
### Tests
228
235
@@ -259,7 +266,9 @@ This will create an empty migration with the next version.
259
266
260
267
### Module versioning notes
261
268
262
-
In order to have good overview of what version of package contains what kind of migrations, this package follows this versioning schema: `0.<versionOfLastMigration>.<patches>`.
269
+
In order to have good overview of what version of package contains what kind of migration, to every release there
270
+
should be appended version's metadata in format `migr-<versionOfLatestMigration>`. If for releasing is used `aegir`
Copy file name to clipboardExpand all lines: run.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ If you run into any trouble, please feel free to [open an issue in this reposito
13
13
The migration tool is safe -- it should not delete any data. If you have important data stored _only_ in your ipfs node, and want to be extra safe, you can back up the whole repo with:
14
14
15
15
```sh
16
-
cp -r ~/.js-ipfs~/.js-ipfs.bak
16
+
cp -r ~/.jsipfs~/.jsipfs.backup
17
17
```
18
18
19
19
## Step 1. Downloading the Migration
@@ -26,16 +26,16 @@ To run the migration tool:
26
26
27
27
```sh
28
28
# to check if there are migrations that need to be applied
29
-
js-ipfs-repo-migrations status
29
+
jsipfs-repo-migrations status
30
30
31
31
# if so, migrate to the latest version
32
-
js-ipfs-repo-migrations migrate
32
+
jsipfs-repo-migrations migrate
33
33
```
34
34
35
35
## Step 3. Done! Run IPFS.
36
36
37
37
If the migration completed without error, then you're done! Try running the new ipfs:
0 commit comments