From 14616fd2eb86c1688045331c579aa657358c48e9 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Sun, 24 May 2026 13:29:56 +0100 Subject: [PATCH] Query rules by source host directly instead of loading project rules --- src/Appwrite/Platform/Workers/Migrations.php | 21 +++++++------------- 1 file changed, 7 insertions(+), 14 deletions(-) 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);