ah-sequelize-plugin
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -5,2 +5,3 @@ exports.default = { | ||
"autoMigrate" : true, | ||
"loadFixtures": false, | ||
"database" : "DEVELOPMENT_DB", | ||
@@ -38,2 +39,3 @@ "dialect" : "mysql", | ||
// "autoMigrate" : false, | ||
// "loadFixtures": false, | ||
// "logging" : false, | ||
@@ -40,0 +42,0 @@ // "database" : "PRODUCTION_DB", |
@@ -46,11 +46,23 @@ var path = require('path'); | ||
if(api.env === "test"){ | ||
var SequelizeFixtures = require('sequelize-fixtures'); | ||
SequelizeFixtures.loadFile(api.projectRoot + '/test/fixtures/*.json', api.models, function(){ | ||
SequelizeFixtures.loadFile(api.projectRoot + '/test/fixtures/*.yml', api.models, function(){ | ||
api.sequelize.test(next); | ||
api.sequelize.test(next); | ||
}, | ||
loadFixtures: function(next) { | ||
if(api.config.sequelize.loadFixtures) { | ||
var SequelizeFixtures = require('sequelize-fixtures'); | ||
SequelizeFixtures.loadFile(api.projectRoot + '/test/fixtures/*.{json,yml,js}', api.models, function () { | ||
next(); | ||
}); | ||
}); | ||
}else{ | ||
api.sequelize.test(next); | ||
} else { | ||
next(); | ||
} | ||
}, | ||
autoMigrate: function(next) { | ||
if(api.config.sequelize.autoMigrate == null || api.config.sequelize.autoMigrate) { | ||
api.sequelize.migrate({method: 'up'}, function () { | ||
next(); | ||
}); | ||
} else { | ||
next(); | ||
} | ||
@@ -85,9 +97,7 @@ }, | ||
if(api.config.sequelize.autoMigrate) { | ||
api.sequelize.migrate({method: 'up'}, next) | ||
} else { | ||
next(err); | ||
} | ||
api.sequelize.autoMigrate(function() { | ||
api.sequelize.loadFixtures(next); | ||
}); | ||
}); | ||
} | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"description": "I use sequelize in actionhero as an ORM", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"homepage": "http://actionherojs.com", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -127,2 +127,4 @@ # ah-sequelize-plugin | ||
We use the `sequelize-fixtures` package to load in JSON-defined fixtures in the test NODE\_ENV. Store your fixtures in `./test/fixtures/*.json` or `./test/fixtures/*.yml` | ||
We use the `sequelize-fixtures` package to load in JSON-defined fixtures in the test NODE\_ENV. Store your fixtures in `./test/fixtures/*.json` or `./test/fixtures/*.yml`. | ||
By default, `ah-sequelize-plugin` will **not** automatically load your fixtures when Actionhero starts up. You can enable this behaviour by adding `loadFixtures: true` to your sequelize config. |
11439
167
130