ah-sequelize-plugin
Advanced tools
Comparing version 0.0.5 to 0.1.0
@@ -18,7 +18,14 @@ var path = require('path'); | ||
migrate: function(next){ | ||
migrate: function(opts, next){ | ||
if(typeof opts === "function"){ | ||
next = opts; | ||
opts = null; | ||
} | ||
opts = opts === null ? { method: 'up' } : opts; | ||
var migrator = api.sequelize.sequelize.getMigrator({ | ||
path: api.project_root + '/migrations' | ||
}); | ||
migrator.migrate({ method: 'up' }).success(function() { | ||
migrator.migrate(opts).success(function() { | ||
next(); | ||
@@ -28,2 +35,6 @@ }); | ||
migrateUndo: function(next) { | ||
this.migrate({ method: 'down' }, next); | ||
}, | ||
connect: function(next){ | ||
@@ -30,0 +41,0 @@ var self = this; |
@@ -5,3 +5,3 @@ { | ||
"description": "I use sequelize in actionhero as an ORM", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"homepage": "http://actionherojs.com", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -32,3 +32,4 @@ # ah-sequelize-plugin | ||
You can add a migration grunt helper to your actionhero project by adding the below to your `gruntfile.js`: | ||
You can use the [sequelize-cli](http://sequelizejs.com/docs/latest/migrations#cli) for more utilities or | ||
you can add a migration grunt helper(s) to your actionhero project by adding the below to your `gruntfile.js`: | ||
@@ -46,2 +47,15 @@ ```javascript | ||
To migrate down also add the following: | ||
```javascript | ||
grunt.registerTask('migrate:undo','revert and run the “down” action on the last run migration',function(file){ | ||
var done = this.async(); | ||
init(function(api){ | ||
api.sequelize.migrateUndo(function(){ | ||
done(); | ||
}) | ||
}) | ||
}) | ||
``` | ||
## [Associations](http://sequelizejs.com/docs/latest/associations) | ||
@@ -48,0 +62,0 @@ |
7234
132
84