Skip to content

Commit

Permalink
fix: check for exports.seed in seed files
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinl committed Apr 1, 2019
1 parent 032aded commit 2f83acb
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions lib/DatabaseManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,27 @@ DatabaseManager.prototype.updateIdSequences = function() {
* @param {String=} populatePathPattern
* @returns {Promise}
*/
DatabaseManager.prototype.populateDb = function(populatePathPattern) {
populatePathPattern = populatePathPattern || this.config.populatePathPattern;

var knex = this.knexInstance();
var modules = multiRequire(populatePathPattern).filterModule(_.isFunction).require();

return Promise
.all(_.map(modules, function (module) {
return knex.transaction(function (trx) {
return module.module(trx);
});
}));
};
DatabaseManager.prototype.populateDb = function(populatePathPattern) {
populatePathPattern =
populatePathPattern || this.config.dbManager.populatePathPattern;

var knex = this.knexInstance();
var modules = multiRequire(populatePathPattern)
.filterModule(function(module) {
return _.isFunction(module.seed);
})
.require();

return Promise.all(
_.map(modules, function(module) {
return knex.transaction(function(trx) {
return module.module.seed(trx).then(res => {
return module.fileName;
});
});
})
);
}

/**
* Runs migrations for database in knex config.
Expand Down

0 comments on commit 2f83acb

Please sign in to comment.