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.
This commit is contained in:
Prem Palanisamy committed 2026-05-11 06:52:23 +01:00
1 parent 04a6eaf5d4
commit a902c25363
1 file changed
+14 -4
+14 -4
View File
@@ -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