From 1518ecd1e981ade371bea9c11e06844159116d3a Mon Sep 17 00:00:00 2001 From: chaptergy <26956711+chaptergy@users.noreply.github.com> Date: Fri, 6 Nov 2020 12:29:38 +0100 Subject: [PATCH] Adds autoremove of failed certificate creations in DB --- backend/internal/certificate.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/internal/certificate.js b/backend/internal/certificate.js index 19e0592..3725c1c 100644 --- a/backend/internal/certificate.js +++ b/backend/internal/certificate.js @@ -216,6 +216,13 @@ const internalCertificate = { return saved_row; }); }); + }).catch(async (error) => { + // Delete the certificate from the database if it was not created successfully + await certificateModel + .query() + .deleteById(certificate.id); + + throw error; }); } else { return certificate;