diff --git a/lib/DatabaseManager.js b/lib/DatabaseManager.js index 0e96a3d..5db7b91 100644 --- a/lib/DatabaseManager.js +++ b/lib/DatabaseManager.js @@ -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.