diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 9a37d4e6db..45599f4be3 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -340,6 +340,9 @@ class Migrations extends Action $migrationDocument->setAttribute('errors', $errorMessages); } } finally { + if ($tempAPIKey) { + $this->removeAPIKey($tempAPIKey); + } if ($migrationDocument) { $this->updateMigrationDocument($migrationDocument, $projectDocument); @@ -347,9 +350,6 @@ class Migrations extends Action throw new Exception(implode("\n", $migrationDocument->getAttribute('errors', [])); } } - if ($tempAPIKey) { - $this->removeAPIKey($tempAPIKey); - } } } }