0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/data/migrations/init/2-create-fixtures.js
Hannah Wolfe a1ad9f2870
Reworked init migrations to use async/await (#13635)
- use async/await and fat arrow syntax
- makes it easier to refactor later as "this" context is then reliable
2021-10-21 11:19:59 +01:00

26 lines
805 B
JavaScript

const Promise = require('bluebird');
const _ = require('lodash');
const fixtures = require('../../schema/fixtures');
const logging = require('@tryghost/logging');
module.exports.config = {
transaction: true
};
module.exports.up = async (options) => {
const localOptions = _.merge({
context: {internal: true},
migrating: true
}, options);
await Promise.mapSeries(fixtures.models, async (model) => {
logging.info('Model: ' + model.name);
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);
});
};