From a902c25363edbed6cad64fcba5df342d9bee6e3d Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 11 May 2026 06:51:56 +0100 Subject: [PATCH] refactor(migrations): extract destination DSN resolver to named method Replaces the inline match closure with resolveDestinationDatabaseDsn(), mirroring cloud's worker. Adds a docblock explaining why documentsdb / vectorsdb keep the source DSN. --- src/Appwrite/Platform/Workers/Migrations.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 41f82f4dd0..b4b8893b62 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -293,10 +293,7 @@ class Migrations extends Action $this->getDatabasesDB, Config::getParam('collections', [])['databases']['collections'], OnDuplicate::tryFrom($options['onDuplicate'] ?? '') ?? OnDuplicate::Fail, - fn (ResourceDatabase $resource) => match ($resource->getType()) { - DATABASE_TYPE_DOCUMENTSDB, DATABASE_TYPE_VECTORSDB => (string) $resource->getDatabase(), - default => (string) $this->project->getAttribute('database', ''), - }, + $this->resolveDestinationDatabaseDsn(...), ), DestinationCSV::getName() => new DestinationCSV( $this->deviceForFiles, @@ -320,6 +317,19 @@ class Migrations extends Action }; } + /** + * Legacy / tablesdb databases route to the destination project's DSN (same as a fresh + * Databases create), while documentsdb / vectorsdb keep the source DSN — the dedicated-DB + * backfill that would re-point them is not run during migrations. + */ + private function resolveDestinationDatabaseDsn(ResourceDatabase $resource): string + { + return match ($resource->getType()) { + DATABASE_TYPE_DOCUMENTSDB, DATABASE_TYPE_VECTORSDB => (string) $resource->getDatabase(), + default => (string) $this->project->getAttribute('database', ''), + }; + } + /** * @throws AuthorizationException * @throws Structure