From b827043cb7d799f357f37f1a4c98e9fa3e0a3ed8 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 2 Mar 2026 09:11:44 +0000 Subject: [PATCH] fix: skip deployment import when parent resource already exists in destination When a function or site already exists in the destination, the API returns 409 and the parent resource is marked as error. Previously, deployments for that parent would still be imported, creating duplicates. Now importDeployment and importSiteDeployment check the parent status and throw an error if it failed. --- src/Migration/Destinations/Appwrite.php | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index a128c73d0e..8c6281aac7 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -1473,7 +1473,18 @@ class Appwrite extends Destination */ private function importDeployment(Deployment $deployment): Resource { - $functionId = $deployment->getFunction()->getId(); + $function = $deployment->getFunction(); + + if ($function->getStatus() === Resource::STATUS_ERROR) { + throw new Exception( + resourceName: $deployment->getName(), + resourceGroup: $deployment->getGroup(), + resourceId: $deployment->getId(), + message: 'Function "' . $function->getId() . '" already exists in destination', + ); + } + + $functionId = $function->getId(); $response = null; @@ -1674,7 +1685,18 @@ class Appwrite extends Destination */ private function importSiteDeployment(SiteDeployment $deployment): Resource { - $siteId = $deployment->getSite()->getId(); + $site = $deployment->getSite(); + + if ($site->getStatus() === Resource::STATUS_ERROR) { + throw new Exception( + resourceName: $deployment->getName(), + resourceGroup: $deployment->getGroup(), + resourceId: $deployment->getId(), + message: 'Site "' . $site->getId() . '" already exists in destination', + ); + } + + $siteId = $site->getId(); if ($deployment->getSize() <= Transfer::STORAGE_MAX_CHUNK_SIZE) { $response = $this->client->call(