From 21334df4cb2af48ae2262a5893e1c338e96fd058 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 4 Feb 2025 17:36:45 +0530 Subject: [PATCH] Update method to rollback to previous version --- packages/backend/src/service.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 86dd6bef..0321df01 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -695,8 +695,8 @@ export class Service { // If a custom domain is present then use that as the DNS in the deployment request const customDomain = await this.db.getOldestDomainByProjectId(data.project!.id!); - // On deleting deployment later, project DNS deployment is also deleted - // So publish project DNS deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later + // On deleting deployment later, project canonical deployment is also deleted + // So publish project canonical deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later const { applicationDeploymentRequestData, applicationDeploymentRequestId } = await this.laconicRegistry.createApplicationDeploymentRequest({ deployment: canonicalDeployment, @@ -791,8 +791,8 @@ export class Service { // If a custom domain is present then use that as the DNS in the deployment request const customDomain = await this.db.getOldestDomainByProjectId(project!.id!); - // On deleting deployment later, project DNS deployment is also deleted - // So publish project DNS deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later + // On deleting deployment later, project canonical deployment is also deleted + // So publish project canonical deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later const { applicationDeploymentRequestId, applicationDeploymentRequestData } = await this.laconicRegistry.createApplicationDeploymentRequest({ deployment: canonicalDeployment, @@ -1218,6 +1218,10 @@ export class Service { { isCurrent: true }, ); + if (!newCurrentDeploymentUpdate || !oldCurrentDeploymentUpdate){ + return false; + } + const newCurrentDeployment = await this.db.getDeployment({ where: { id: deploymentId }, relations: { project: true, deployer: true } }); if (!newCurrentDeployment) { @@ -1255,12 +1259,12 @@ export class Service { log(`Application deployment request record published: ${result.id}`) - await this.db.updateDeploymentById(canonicalDeployment.id, { + const updateResult = await this.db.updateDeploymentById(canonicalDeployment.id, { applicationDeploymentRequestId: result.id, applicationDeploymentRequestData, }); - return newCurrentDeploymentUpdate && oldCurrentDeploymentUpdate; + return updateResult; } async deleteDeployment(deploymentId: string): Promise {