mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Query rules by source host directly instead of loading project rules
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user