Skip to content

Commit b5861e7

Browse files
authored
Merge pull request #666 from eisbilir/feature/new-milestone-concept
fix: product delete sync with ES
2 parents 7a73858 + 8114e13 commit b5861e7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/routes/phaseProducts/delete.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = [
1717
const phaseId = _.parseInt(req.params.phaseId);
1818
const productId = _.parseInt(req.params.productId);
1919

20-
models.sequelize.transaction(() =>
20+
models.sequelize.transaction(transaction =>
2121
// soft delete the record
2222
models.PhaseProduct.findOne({
2323
where: {
@@ -34,17 +34,17 @@ module.exports = [
3434
err.status = 404;
3535
return Promise.reject(err);
3636
}
37-
return existing.update({ deletedBy: req.authUser.userId });
37+
return existing.update({ deletedBy: req.authUser.userId }, { transaction });
3838
})
39-
.then(entity => entity.destroy()))
39+
.then(entity => entity.destroy({ transaction })))
4040
.then((deleted) => {
4141
req.log.debug('deleted phase product', JSON.stringify(deleted, null, 2));
4242
// emit the event
4343
util.sendResourceToKafkaBus(
4444
req,
4545
EVENT.ROUTING_KEY.PROJECT_PHASE_PRODUCT_REMOVED,
4646
RESOURCES.PHASE_PRODUCT,
47-
_.pick(deleted.toJSON(), ['id', 'projectId']));
47+
_.pick(deleted.toJSON(), ['id', 'projectId', 'phaseId']));
4848

4949
res.status(204).json({});
5050
})

0 commit comments

Comments
 (0)