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