Query rules by source host directly instead of loading project rules

This commit is contained in:
Prem Palanisamy
2026-05-24 13:29:56 +01:00
parent 0cdb13b398
commit 14616fd2eb
+7 -14
View File
@@ -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);