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.
Copy file name to clipboardExpand all lines: README.md
+22-10Lines changed: 22 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -94,19 +94,18 @@ a case, you should provide a way how to trigger migrations manually.**
94
94
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:
95
95
96
96
- SAFE. No data lost. Ever.
97
-
- Revertible. Tools must implement forward and backward migrations.
98
-
-Frozen. After the tool is written, all code must be frozen and vendored.
97
+
- Revertible. Tools must implement forward and backward (if possible) migrations.
98
+
-Tests. Migrations have to be well tested.
99
99
- To Spec. The tools must conform to the spec.
100
100
101
101
#### Architecture of migrations
102
102
103
-
All migrations are placed in `/migrations` folder. Each folder there represents one migration that behaves as stand-alone
104
-
package that has its own `package.json` file that states migration's dependencies, has its own tests and follows migration
105
-
API.
103
+
All migrations are placed in `/migrations` folder. Each folder there represents one migration that follows migration
104
+
API.
106
105
107
106
All migrations are collected in `/migrations/index.js`, which should not be edited manually is it is regenerated on
108
107
every run of `jsipfs-migrations add` (or the manual changes should follow same style of modifications).
109
-
The order of migrations is important and the migrations have to be sorted in the growing order.
108
+
**The order of migrations is important and the migrations have to be sorted in the growing order**.
110
109
111
110
Each migration has to follow this API. It has to export object in its `index.js` that has following properties:
112
111
@@ -164,11 +163,24 @@ write the rest of migration!
164
163
The `node_modules` of the migration should be committed to the repo to ensure that the dependencies are resolved even in
165
164
far future, when the package might be removed from registry.
166
165
166
+
#### Migration's dependencies
167
+
168
+
Size of `js-ipfs`'s bundle is crucial for distribution in browser environment, hence dependency management of all related
169
+
packages is important.
170
+
171
+
If migration need to depend on some package, this dependency should be declared in the root's `package.json`. Author
172
+
of migrations should be thoughtful about adding dependencies that would significantly increase the size of the final bundle.
173
+
174
+
Most of the migration's dependencies will most likely overlap with `js-ipfs`'s dependencies and hence should not introduce
175
+
any significant overhead, but it requires to keep the versions of these dependencies in sync with `js-ipfs`. For this
176
+
reason migrations should be well tested to ensure correct behaviour over its dependencies updates. It might happen
177
+
that update of some dependency could introduce breaking change, in such a case the next steps should be discussed with broader
178
+
audience.
179
+
167
180
#### Integration with js-ipfs
168
181
169
-
When 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.
170
-
After releasing the updated version of `js-ipfs-repo` this version should be propagated into `js-ipfs` together with
171
-
updated version of this package.
182
+
When 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,
183
+
together with updated version of this package. And afterwards propagate the updated version to `js-ipfs`.
172
184
173
185
#### Tests
174
186
@@ -179,7 +191,7 @@ If migration affects working of any of the following functionality, it has to pr
179
191
*`/src/repo/lock.js`:`lock()` - locking repository that uses file system
180
192
*`/src/repo/lock-memory.js`:`lock()` - locking repository that uses memory
181
193
182
-
Migration has to have a test coverage. Tests for migration should be placed in `/test/migrations/` folder. Most probably
194
+
Every mgration has to have a test coverage. Tests for migration should be placed in `/test/migrations/` folder. Most probably
183
195
you will have to plug the tests into `browser.js`/`node.js` if they require specific bootstrap on each platform.
0 commit comments