不要怂,就是干,撸起袖子干!

Commit f0a77cae by Cameron Pitt

Update migrations.md

1 parent 720d4d88
Showing with 1 additions and 18 deletions
...@@ -273,25 +273,8 @@ migration.removeIndex('Person', ['firstname', 'lastname']) ...@@ -273,25 +273,8 @@ migration.removeIndex('Person', ['firstname', 'lastname'])
``` ```
## Programmatic use ## Programmatic use
Sequelize has a [sister library](https://github.com/sequelize/umzug) for programmatically handling execution and logging of migration tasks.
If you need to interact with the migrator within your code, you can easily achieve that via `sequelize.getMigrator`. You can specify the path to your migrations as well as a pattern which represents the files that contain the migrations.
```js
var migrator = sequelize.getMigrator({
path: process.cwd() + '/database/migrations',
filesFilter: /\.coffee$/
})
```
Once you have a migrator object, you can run its migration with `migrator.migrate`. By default, this will execute all the up methods within your pending migrations. If you want to rollback a migration, just call it like this:
```js
migrator
.migrate({ method: 'down' })
.then(function() {
// The migrations have been executed!
})
```
[0]: http://gulpjs.com/ [0]: http://gulpjs.com/
[1]: https://github.com/sequelize/cli [1]: https://github.com/sequelize/cli
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!