From d29740f0d7d79b76636cfaa54177d1822d6e4e32 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 8 Aug 2024 15:43:11 +0300 Subject: [PATCH] credentials --- composer.lock | 12 +++---- src/Appwrite/Platform/Workers/Migrations.php | 37 +++++++++++--------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/composer.lock b/composer.lock index ee21f6f98a..fbf409232b 100644 --- a/composer.lock +++ b/composer.lock @@ -1721,16 +1721,16 @@ }, { "name": "utopia-php/database", - "version": "0.50.2", + "version": "0.50.3", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "c712d1f6c8ec37886a7a1ad4d60a8cd75dec00aa" + "reference": "4287e6625c7273411c7322abd151c4285ee7b50f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/c712d1f6c8ec37886a7a1ad4d60a8cd75dec00aa", - "reference": "c712d1f6c8ec37886a7a1ad4d60a8cd75dec00aa", + "url": "https://api.github.com/repos/utopia-php/database/zipball/4287e6625c7273411c7322abd151c4285ee7b50f", + "reference": "4287e6625c7273411c7322abd151c4285ee7b50f", "shasum": "" }, "require": { @@ -1771,9 +1771,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.50.2" + "source": "https://github.com/utopia-php/database/tree/0.50.3" }, - "time": "2024-07-31T10:12:19+00:00" + "time": "2024-08-08T01:40:54+00:00" }, { "name": "utopia-php/domains", diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 74bca22206..4fbc83d8e8 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -38,6 +38,8 @@ class Migrations extends Action protected Document $project; + protected array $credentials = []; + public static function getName(): string { return 'migrations'; @@ -125,9 +127,9 @@ class Migrations extends Action $credentials['port'], ), SourceAppwrite::getName() => new SourceAppwrite( - $credentials['projectId'], - $credentials['endpoint'], - $credentials['apiKey'] + $this->credentials['projectId'], + $this->credentials['endpoint'], + $this->credentials['apiKey'] ), default => throw new \Exception('Invalid source type'), }; @@ -139,13 +141,12 @@ class Migrations extends Action protected function processDestination(Document $migration): Destination { $destination = $migration->getAttribute('destination'); - $credentials = $migration->getAttribute('credentials'); return match ($destination) { DestinationAppwrite::getName() => new DestinationAppwrite( - $credentials['projectId'], - $credentials['endpoint'], - $credentials['apiKey'], + $this->credentials['projectId'], + $this->credentials['endpoint'], + $this->credentials['apiKey'], $this->dbForProject, Config::getParam('collections', [])['databases']['collections'], ), @@ -278,16 +279,18 @@ class Migrations extends Action $log->addTag('type', $migration->getAttribute('source')); - if ( - $migration->getAttribute('source') === SourceAppwrite::getName() || - $migration->getAttribute('destination') === DestinationAppwrite::getName() - ) { - $migration->setAttribute('credentials', [ - 'projectId' => $projectDocument->getId(), - 'endpoint' => 'http://appwrite/v1', - 'apiKey' => $tempAPIKey['secret'], - ]); - } +// if ( +// $migration->getAttribute('source') === SourceAppwrite::getName() || +// $migration->getAttribute('destination') === DestinationAppwrite::getName() +// ) { +// $migration->setAttribute('credentials', ); +// } + + $this->credentials = [ + 'projectId' => $projectDocument->getId(), + 'endpoint' => 'http://appwrite/v1', + 'apiKey' => $tempAPIKey['secret'], + ]; $source = $this->processSource($migration); $destination = $this->processDestination($migration);