From 7447d17e94ada573166555e7949909346f2b3b79 Mon Sep 17 00:00:00 2001 From: x032205 Date: Mon, 5 May 2025 17:21:59 -0400 Subject: [PATCH] bug fix, migration fix, frontend tweak --- ...9232917_store-cert-secret-key-and-chain.ts | 18 +++++++++++------ .../certificate/certificate-service.ts | 2 +- .../components/CertificateImportModal.tsx | 20 +++---------------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/backend/src/db/migrations/20250429232917_store-cert-secret-key-and-chain.ts b/backend/src/db/migrations/20250429232917_store-cert-secret-key-and-chain.ts index cb5e44a03..a627bf83c 100644 --- a/backend/src/db/migrations/20250429232917_store-cert-secret-key-and-chain.ts +++ b/backend/src/db/migrations/20250429232917_store-cert-secret-key-and-chain.ts @@ -4,9 +4,12 @@ import { TableName } from "../schemas"; export async function up(knex: Knex): Promise { if (await knex.schema.hasTable(TableName.CertificateBody)) { - await knex.schema.alterTable(TableName.CertificateBody, (t) => { - t.binary("encryptedCertificateChain").nullable(); - }); + const hasColumn = await knex.schema.hasColumn(TableName.CertificateBody, "encryptedCertificateChain"); + if (!hasColumn) { + await knex.schema.alterTable(TableName.CertificateBody, (t) => { + t.binary("encryptedCertificateChain").nullable(); + }); + } } if (!(await knex.schema.hasTable(TableName.CertificateSecret))) { @@ -26,8 +29,11 @@ export async function down(knex: Knex): Promise { } if (await knex.schema.hasTable(TableName.CertificateBody)) { - await knex.schema.alterTable(TableName.CertificateBody, (t) => { - t.dropColumn("encryptedCertificateChain"); - }); + const hasColumn = await knex.schema.hasColumn(TableName.CertificateBody, "encryptedCertificateChain"); + if (hasColumn) { + await knex.schema.alterTable(TableName.CertificateBody, (t) => { + t.dropColumn("encryptedCertificateChain"); + }); + } } } diff --git a/backend/src/services/certificate/certificate-service.ts b/backend/src/services/certificate/certificate-service.ts index 634fe791b..927fab4ad 100644 --- a/backend/src/services/certificate/certificate-service.ts +++ b/backend/src/services/certificate/certificate-service.ts @@ -485,7 +485,7 @@ export const certificateServiceFactory = ({ await certificateSecretDAL.create( { - certId: cert.id, + certId: txCert.id, encryptedPrivateKey }, tx diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx index 2331d0810..c4cffe7b0 100644 --- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx +++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx @@ -175,11 +175,7 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle }: Props) => { errorText={error?.message} isRequired > -