From 9196e74437a3325309db98a6e2291f23199ec1ef Mon Sep 17 00:00:00 2001 From: Fang-Pen Lin Date: Thu, 30 Oct 2025 10:07:31 -0700 Subject: [PATCH] Add more missing columns --- backend/src/db/migrations/20251029234547_add-pki-acme.ts | 5 +++++ backend/src/db/schemas/pki-acme-orders.ts | 3 ++- backend/src/ee/services/pki-acme/pki-acme-service.ts | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/src/db/migrations/20251029234547_add-pki-acme.ts b/backend/src/db/migrations/20251029234547_add-pki-acme.ts index 6390e5812..fdc481a04 100644 --- a/backend/src/db/migrations/20251029234547_add-pki-acme.ts +++ b/backend/src/db/migrations/20251029234547_add-pki-acme.ts @@ -78,6 +78,11 @@ export async function up(knex: Knex): Promise { t.uuid("accountId").notNullable(); t.foreign("accountId").references("id").inTable(TableName.PkiAcmeAccount).onDelete("CASCADE"); + t.timestamp("notBefore").nullable(); + t.timestamp("notAfter").nullable(); + + t.timestamp("expiresAt").notNullable(); + // Order status t.string("status").notNullable(); // pending, ready, processing, valid, invalid diff --git a/backend/src/db/schemas/pki-acme-orders.ts b/backend/src/db/schemas/pki-acme-orders.ts index 5f18a3b8c..5ed58e4e9 100644 --- a/backend/src/db/schemas/pki-acme-orders.ts +++ b/backend/src/db/schemas/pki-acme-orders.ts @@ -14,7 +14,8 @@ export const PkiAcmeOrdersSchema = z.object({ createdAt: z.date(), updatedAt: z.date(), notBefore: z.date().nullable().optional(), - notAfter: z.date().nullable().optional() + notAfter: z.date().nullable().optional(), + expiresAt: z.date().nullable().optional() }); export type TPkiAcmeOrders = z.infer; diff --git a/backend/src/ee/services/pki-acme/pki-acme-service.ts b/backend/src/ee/services/pki-acme/pki-acme-service.ts index c68bb3895..e5336b69c 100644 --- a/backend/src/ee/services/pki-acme/pki-acme-service.ts +++ b/backend/src/ee/services/pki-acme/pki-acme-service.ts @@ -339,7 +339,11 @@ export const pkiAcmeServiceFactory = ({ const createdOrder = await acmeOrderDAL.create( { accountId: account.id, - status: AcmeOrderStatus.Pending + status: AcmeOrderStatus.Pending, + notBefore: payload.notBefore ? new Date(payload.notBefore) : undefined, + notAfter: payload.notAfter ? new Date(payload.notAfter) : undefined, + // TODO: read config from the profile to get the expiration time instead + expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000) }, tx );