From a4fd4ef6351d81df38ebae4bc64535259b89e3d9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 29 Nov 2023 12:28:13 +0100 Subject: [PATCH] Save history --- .../src/appMigrations/appMigrationMetadata.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/server/src/appMigrations/appMigrationMetadata.ts b/packages/server/src/appMigrations/appMigrationMetadata.ts index 828bca31f4..1df0b266ae 100644 --- a/packages/server/src/appMigrations/appMigrationMetadata.ts +++ b/packages/server/src/appMigrations/appMigrationMetadata.ts @@ -3,6 +3,7 @@ import { Database, DocumentType, Document } from "@budibase/types" export interface AppMigrationDoc extends Document { version: string + history: Record } const EXPIRY_SECONDS = Duration.fromDays(1).toSeconds() @@ -31,7 +32,7 @@ export async function getAppMigrationMetadata(appId: string): Promise { throw err } - metadata = { version: "" } + metadata = { version: "", history: {} } } await cache.store(cacheKey, metadata, EXPIRY_SECONDS) @@ -49,7 +50,15 @@ export async function updateAppMigrationMetadata({ }): Promise { const db = context.getAppDB() const appMigrationDoc = await getFromDB(appId) - await db.put({ ...appMigrationDoc, version }) + const updatedMigrationDoc: AppMigrationDoc = { + ...appMigrationDoc, + version, + history: { + ...appMigrationDoc.history, + [version]: { runAt: Date.now() }, + }, + } + await db.put(updatedMigrationDoc) const cacheKey = getCacheKey(appId)