2016-10-12 17:18:57 +02:00
|
|
|
var Promise = require('bluebird'),
|
|
|
|
_ = require('lodash'),
|
|
|
|
fixtures = require('../../schema/fixtures'),
|
2017-12-11 22:47:46 +01:00
|
|
|
common = require('../../../lib/common');
|
2016-10-12 17:18:57 +02:00
|
|
|
|
2017-12-05 09:14:55 +01:00
|
|
|
module.exports.config = {
|
|
|
|
transaction: true
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.up = function insertFixtures(options) {
|
2016-10-12 17:18:57 +02:00
|
|
|
var localOptions = _.merge({
|
|
|
|
context: {internal: true}
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
return Promise.mapSeries(fixtures.models, function (model) {
|
2017-12-11 22:47:46 +01:00
|
|
|
common.logging.info('Model: ' + model.name);
|
2017-06-13 16:27:42 +07:00
|
|
|
|
2016-10-12 17:18:57 +02:00
|
|
|
return fixtures.utils.addFixturesForModel(model, localOptions);
|
|
|
|
}).then(function () {
|
|
|
|
return Promise.mapSeries(fixtures.relations, function (relation) {
|
2017-12-11 22:47:46 +01:00
|
|
|
common.logging.info('Relation: ' + relation.from.model + ' to ' + relation.to.model);
|
2016-10-12 17:18:57 +02:00
|
|
|
return fixtures.utils.addFixturesForRelation(relation, localOptions);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|