Skip to content

Commit a7f4838

Browse files
authored
Merge pull request #90 from BastienRodz/br-dev-AsyncMigration
Run async migrations in sequence
2 parents 57e6b08 + af80743 commit a7f4838

File tree

6 files changed

+300
-984
lines changed

6 files changed

+300
-984
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,22 @@ Migrations.add({
205205
});
206206
```
207207
208-
For Meteor 2.8+ you can pass async function directly.
208+
Starting from Meteor 2.8+, you can use async functions directly in your migrations:
209+
210+
```js
211+
Migrations.add({
212+
version: 3,
213+
name: 'Add belts to people wearing pants.',
214+
up: async function () {
215+
// Asynchronous migration code
216+
await SomeCollection.updateAsync({ wearsPants: true }, { $set: { hasBelt: true } }, { multi: true });
217+
},
218+
down: async function () {
219+
// Asynchronous rollback code
220+
await SomeCollection.updateAsync({}, { $unset: { hasBelt: true } }, { multi: true });
221+
},
222+
});
223+
```
209224
210225
* Note: You may want to call migration after startup in case your host (such as Heroku) limits the amount of time given for startup
211226
``` javascript

0 commit comments

Comments
 (0)