Merge pull request #9709 from appwrite/source-report

Add: Source report method
This commit is contained in:
Jake Barnby 2025-05-01 06:23:57 +00:00 committed by GitHub
commit b922858428
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,6 +34,13 @@ class Migrations extends Action
protected Document $project;
/**
* Cached for performance.
*
* @var array<string, int>
*/
private array $sourceReport = [];
/**
* @var callable
*/
@ -101,7 +108,7 @@ class Migrations extends Action
$source = $migration->getAttribute('source');
$credentials = $migration->getAttribute('credentials');
return match ($source) {
$migrationSource = match ($source) {
Firebase::getName() => new Firebase(
json_decode($credentials['serviceAccount'], true),
),
@ -130,6 +137,10 @@ class Migrations extends Action
),
default => throw new \Exception('Invalid source type'),
};
$this->sourceReport = $migrationSource->report();
return $migrationSource;
}
/**
@ -245,8 +256,6 @@ class Migrations extends Action
$source = $this->processSource($migration);
$destination = $this->processDestination($migration, $tempAPIKey);
$source->report();
$transfer = new Transfer(
$source,
$destination
@ -381,4 +390,16 @@ class Migrations extends Action
}
}
}
/**
* Returns a report of resources in the source.
*
* Should be called after `processSource()` to ensure the data is populated.
*
* @return array<string, int> Resource type mapped to their counts.
*/
protected function getSourceReport(): array
{
return $this->sourceReport;
}
}