From d137b41c0b970d033aa5722e08d55ed2d3e7f72e Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 1 May 2025 11:22:19 +0530 Subject: [PATCH 1/3] add: expose source report for cloud. --- src/Appwrite/Platform/Workers/Migrations.php | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 4939dc8143..db156d7798 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -34,6 +34,13 @@ class Migrations extends Action protected Document $project; + /** + * Accessed on cloud for telemetry. + * + * @type array + */ + 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; } /** @@ -381,4 +392,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 Resource type mapped to their counts. + */ + protected function getSourceReport(): array + { + return $this->sourceReport; + } } From 606fea5871a9499a6a3fb5284e14c1f1af606ba4 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 1 May 2025 11:31:51 +0530 Subject: [PATCH 2/3] address comments. --- src/Appwrite/Platform/Workers/Migrations.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index db156d7798..3e8317e5e6 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -35,9 +35,9 @@ class Migrations extends Action protected Document $project; /** - * Accessed on cloud for telemetry. + * Cached for performance. * - * @type array + * @var array */ private array $sourceReport = []; From 8c7ccfcc126820e71eff67d221e00c13a68ca85c Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 1 May 2025 11:37:58 +0530 Subject: [PATCH 3/3] address comments. --- src/Appwrite/Platform/Workers/Migrations.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 3e8317e5e6..f2d7293c66 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -256,8 +256,6 @@ class Migrations extends Action $source = $this->processSource($migration); $destination = $this->processDestination($migration, $tempAPIKey); - $source->report(); - $transfer = new Transfer( $source, $destination