2020-04-29 18:44:27 +03:00
|
|
|
const Promise = require('bluebird');
|
|
|
|
const _ = require('lodash');
|
|
|
|
const fixtures = require('../../schema/fixtures');
|
2021-06-15 17:36:27 +03:00
|
|
|
const logging = require('@tryghost/logging');
|
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) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const 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) {
|
2020-05-25 11:48:50 +03:00
|
|
|
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) {
|
2020-05-25 11:48:50 +03:00
|
|
|
logging.info('Relation: ' + relation.from.model + ' to ' + relation.to.model);
|
2016-10-12 18:18:57 +03:00
|
|
|
return fixtures.utils.addFixturesForRelation(relation, localOptions);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|