2020-04-29 16:44:27 +01:00
|
|
|
const Promise = require('bluebird');
|
|
|
|
const _ = require('lodash');
|
|
|
|
const fixtures = require('../../schema/fixtures');
|
2021-06-15 15:36:27 +01:00
|
|
|
const logging = require('@tryghost/logging');
|
2016-10-12 17:18:57 +02:00
|
|
|
|
2017-12-05 09:14:55 +01:00
|
|
|
module.exports.config = {
|
|
|
|
transaction: true
|
|
|
|
};
|
|
|
|
|
2021-10-21 11:19:59 +01:00
|
|
|
module.exports.up = async (options) => {
|
2020-04-29 16:44:27 +01:00
|
|
|
const localOptions = _.merge({
|
2018-07-24 14:37:17 +02:00
|
|
|
context: {internal: true},
|
|
|
|
migrating: true
|
2016-10-12 17:18:57 +02:00
|
|
|
}, options);
|
|
|
|
|
2021-10-21 11:19:59 +01:00
|
|
|
await Promise.mapSeries(fixtures.models, async (model) => {
|
2020-05-25 03:48:50 -05:00
|
|
|
logging.info('Model: ' + model.name);
|
2017-06-13 16:27:42 +07:00
|
|
|
|
2021-10-21 11:19:59 +01:00
|
|
|
await fixtures.utils.addFixturesForModel(model, localOptions);
|
|
|
|
});
|
|
|
|
|
|
|
|
await Promise.mapSeries(fixtures.relations, async (relation) => {
|
|
|
|
logging.info('Relation: ' + relation.from.model + ' to ' + relation.to.model);
|
|
|
|
await fixtures.utils.addFixturesForRelation(relation, localOptions);
|
2016-10-12 17:18:57 +02:00
|
|
|
});
|
|
|
|
};
|