Skip to content

Commit

Permalink
Throw exception to rollback transaction if sql migration fails
Browse files Browse the repository at this point in the history
  • Loading branch information
cham11ng committed Mar 23, 2021
1 parent 8ae0cbc commit 7cd8016
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/migration/KnexMigrationSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class KnexMigrationSource {
* @returns {string}
*/
getMigrationName(migration: string): string {
this.log('getMigrationName - resolve: ', migration);

return migration;
}

Expand Down
6 changes: 6 additions & 0 deletions src/service/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,11 @@ export async function executeOperation<T extends OperationContext>(
await context.params.onFailed(result);
}

if (result.error) {
logDb('Result:\n%O', result);

throw result.error
}

return result;
}

0 comments on commit 7cd8016

Please sign in to comment.