From 2284f202070aa2e49156cc52b3b1596a7d5aadec Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 29 Jul 2019 11:59:29 +0200 Subject: Add gitlab ci support --- server/helpers/database-utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'server/helpers') diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index 39c74b2fd..6c5068fb0 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts @@ -2,6 +2,7 @@ import * as retry from 'async/retry' import * as Bluebird from 'bluebird' import { Model } from 'sequelize-typescript' import { logger } from './logger' +import { Transaction } from 'sequelize' function retryTransactionWrapper ( functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise | Bluebird, @@ -72,11 +73,18 @@ function resetSequelizeInstance (instance: Model, savedFields: object) { }) } +function afterCommitIfTransaction (t: Transaction, fn: Function) { + if (t) return t.afterCommit(() => fn()) + + return fn() +} + // --------------------------------------------------------------------------- export { resetSequelizeInstance, retryTransactionWrapper, transactionRetryer, - updateInstanceWithAnother + updateInstanceWithAnother, + afterCommitIfTransaction } -- cgit v1.2.3