Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run async migrations in sequence #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,22 @@ Migrations.add({
});
```

For Meteor 2.8+ you can pass async function directly.
Starting from Meteor 2.8+, you can use async functions directly in your migrations:

```js
Migrations.add({
version: 3,
name: 'Add belts to people wearing pants.',
up: async function () {
// Asynchronous migration code
await SomeCollection.updateAsync({ wearsPants: true }, { $set: { hasBelt: true } }, { multi: true });
},
down: async function () {
// Asynchronous rollback code
await SomeCollection.updateAsync({}, { $unset: { hasBelt: true } }, { multi: true });
},
});
```

* Note: You may want to call migration after startup in case your host (such as Heroku) limits the amount of time given for startup
``` javascript
Expand Down
Loading