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.
fix: require passing repo options to migrator (#31)
Adds the changes released in `1.0.1` to master.
BREAKING CHANGES:
- `migrator.migrate(path, version, opts)` has changed to `migrator.migrate(path, repoOpts, version, opts)`
- `migrator.revert(path, version, opts)` has changed to `migrator.revert(path, repoOpts, version, opts)`
@@ -50,7 +49,6 @@ This package is inspired by the [go-ipfs repo migration tool](https://github.com
50
49
51
50
## Background
52
51
53
-
54
52
As js-ipfs evolves and new technologies, algorithms and data structures are incorporated it is necessary to
55
53
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/blob/master/REPO.md), [JS implementation](https://github.com/ipfs/js-ipfs-repo) ).
56
54
So the IPFS repo is versioned, and this package provides a framework to create migrations to transition
Executes a forward migration to a specific version, or to the latest version if a specific version is not specified.
110
113
111
114
**Arguments:**
112
115
113
116
*`path` (string, mandatory) - path to the repo to be migrated
117
+
*`repoOptions` (object, mandatory) - options that are passed to migrations, that use them to construct the datastore. (options are the same as for IPFSRepo).
114
118
*`toVersion` (int, mandatory) - version to which the repo should be migrated.
115
119
*`options` (object, optional) - options for the migration
116
120
*`options.ignoreLock` (bool, optional) - if true will not lock the repo when applying migrations. Use with caution.
117
-
*`options.repoOptions` (object, optional) - options that are passed to migrations, that use them to construct the datastore. (options are the same as for IPFSRepo).
118
121
*`options.onProgress` (function, optional) - callback that is called after finishing execution of each migration to report progress.
119
122
*`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.
120
123
@@ -127,35 +130,24 @@ Signature of the progress callback.
127
130
*`counter` (int) - index of current migration.
128
131
*`totalMigrations` (int) - total count of migrations that will be run.
Executes backward migration to a specific version.
133
136
134
137
**Arguments:**
135
138
136
139
*`path` (string, mandatory) - path to the repo to be reverted
140
+
*`repoOptions` (object, mandatory) - options that are passed to migrations, that use them to construct the datastore. (options are the same as for IPFSRepo).
137
141
*`toVersion` (int, mandatory) - version to which the repo should be reverted to.
138
142
*`options` (object, optional) - options for the reversion
139
143
*`options.ignoreLock` (bool, optional) - if true will not lock the repo when applying migrations. Use with caution.
140
-
*`options.repoOptions` (object, optional) - options that are passed to migrations, that use them to construct the datastore. (options are the same as for IPFSRepo).
141
144
*`options.onProgress` (function, optional) - callback that is called after finishing execution of each migration to report progress.
142
145
*`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.
143
146
144
147
### `getLatestMigrationVersion() -> int`
145
148
146
149
Return the version of the latest migration.
147
150
148
-
## CLI
149
-
150
-
The CLI is a NodeJS binary named `jsipfs-repo-migrations`.
151
-
It has several commands:
152
-
153
-
*`migrate` - performs forward/backward migration to specific or latest version.
154
-
*`status` - check repo for migrations that should be run.
155
-
*`add` - bootstraps new migration.
156
-
157
-
For further details see the `--help` pages.
158
-
159
151
## Creating a new migration
160
152
161
153
Migrations are one of those things that can be extremely painful on users. At the end of the day, we want users never to have to think about it. The process should be:
@@ -174,8 +166,8 @@ be run again.
174
166
All migrations are placed in the `/migrations` folder. Each folder there represents one migration that follows the migration
175
167
API.
176
168
177
-
All migrations are collected in `/migrations/index.js`, which should not be edited manually. It is regenerated on
178
-
every run of `jsipfs-migrations add` (manual changes should follow the same style of modifications).
169
+
All migrations are collected in `/migrations/index.js`, which should not be edited manually.
170
+
179
171
**The order of migrations is important and migrations must be sorted in ascending order**.
180
172
181
173
Each migration must follow this API. It must export an object in its `index.js` that has following properties:
0 commit comments