Ghost/core/server/data/migrations/init/2-create-fixtures.js
kirrg001 6f6c8f4521 Import lib/common only
refs #9178

- avoid importing 4 modules (logging, errors, events and i18n)
- simply require common in each file
2017-12-12 10:28:13 +01:00

26 lines
844 B
JavaScript

var Promise = require('bluebird'),
_ = require('lodash'),
fixtures = require('../../schema/fixtures'),
common = require('../../../lib/common');
module.exports.config = {
transaction: true
};
module.exports.up = function insertFixtures(options) {
var localOptions = _.merge({
context: {internal: true}
}, options);
return Promise.mapSeries(fixtures.models, function (model) {
common.logging.info('Model: ' + model.name);
return fixtures.utils.addFixturesForModel(model, localOptions);
}).then(function () {
return Promise.mapSeries(fixtures.relations, function (relation) {
common.logging.info('Relation: ' + relation.from.model + ' to ' + relation.to.model);
return fixtures.utils.addFixturesForRelation(relation, localOptions);
});
});
};