diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 947c0bddae..c55332bf0a 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -223,22 +223,15 @@ class Migrations extends Action $migrationHost, ]); - // Include the source project's custom API domains so customers using - // a configured custom domain still get the DB fast path. - if (!$this->sourceProject->isEmpty()) { - $rules = $this->dbForPlatform->find('rules', [ - Query::equal('projectInternalId', [$this->sourceProject->getSequence()]), - Query::equal('type', ['api']), - Query::limit(100), - ]); - foreach ($rules as $rule) { - $allowedHosts[] = $rule->getAttribute('domain'); - } - } - // Empty endpoint: processMigration defaults it to the internal host before reaching here. + // Custom API domains are looked up directly in `rules` so customers using + // a configured custom domain still get the DB fast path. $isLocalEndpoint = (is_string($sourceHost) && !empty($allowedHosts) && (new Hostname($allowedHosts))->isValid($sourceHost)) - || (empty($credentials['endpoint']) && $migrationHost !== ''); + || (empty($credentials['endpoint']) && $migrationHost !== '') + || (is_string($sourceHost) && !$this->dbForPlatform->findOne('rules', [ + Query::equal('domain', [$sourceHost]), + Query::equal('type', ['api']), + ])->isEmpty()); $isLocalSource = !$this->sourceProject->isEmpty() && (!$isAppwriteSource || $isLocalEndpoint);