From b409d43e51dbf62331501195ae5a5d2e475a744b Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 3 Feb 2025 17:49:06 +0530 Subject: [PATCH] Update flow for deleting deployments --- packages/backend/src/service.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index bdc23ad1..8755e337 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -716,7 +716,7 @@ export class Service { const environmentVariablesObj = await this.getEnvVariables(data.project!.id!); // If a custom domain is present then use that as the DNS in the deployment request - const domain = await this.db.getOldestDomainByProjectId(data.project!.id!); + const customDomain = await this.db.getOldestDomainByProjectId(data.project!.id!); // To set project DNS if (data.environment === Environment.Production) { @@ -728,7 +728,7 @@ export class Service { appName: repo, repository: repoUrl, environmentVariables: environmentVariablesObj, - dns: domain?.name ?? `${dnsDeployment.project.name}`, + dns: customDomain?.name ?? `${dnsDeployment.project.name}`, lrn: deployer!.deployerLrn!, apiUrl: deployer!.deployerApiUrl!, payment: data.project.txHash, @@ -1280,11 +1280,20 @@ export class Service { return false; } - await this.laconicRegistry.createApplicationDeploymentRemovalRequest({ - deploymentId: dnsDeployment.applicationDeploymentRecordId!, - deployerLrn: dnsDeployment.deployer.deployerLrn, - auctionId: dnsDeployment.project.auctionId, - payment: dnsDeployment.project.txHash + const dnsResult = + await this.laconicRegistry.createApplicationDeploymentRemovalRequest({ + deploymentId: dnsDeployment.applicationDeploymentRecordId!, + deployerLrn: dnsDeployment.deployer.deployerLrn, + auctionId: dnsDeployment.project.auctionId, + payment: dnsDeployment.project.txHash + }); + + await this.db.updateDeploymentById(dnsDeployment.id, { + status: DeploymentStatus.Deleting, + applicationDeploymentRemovalRequestId: + dnsResult.applicationDeploymentRemovalRequestId, + applicationDeploymentRemovalRequestData: + dnsResult.applicationDeploymentRemovalRequestData, }); }