0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Fixed comments fixtures being created in parallel

refs https://ghost.slack.com/archives/C02G9E68C/p1657633760754589?thread_ts=1657624324.578099&cid=C02G9E68C

- The two comment fixtures are created in parallel
- Second one is created while the first one doesn't exist yet, which causes a FK constraint error
This commit is contained in:
Simon Backx 2022-07-12 15:58:33 +02:00
parent e7ccdedb8d
commit 63f2cfdd32

View file

@ -610,9 +610,17 @@ const fixtures = {
},
insertComments: async function insertComments() {
return Promise.map(DataGenerator.forKnex.comments, function (comment) {
// First create the parents (can happen in parallel), because the children depend on those
const parents = DataGenerator.forKnex.comments.filter(c => !c.parent_id);
const children = DataGenerator.forKnex.comments.filter(c => !!c.parent_id);
await Promise.all(parents.map((comment) => {
return models.Comment.add(comment, context.internal);
});
}));
await Promise.all(children.map((comment) => {
return models.Comment.add(comment, context.internal);
}));
},
insertSnippets: function insertSnippets() {