From a6a7f896c1cd5076e82cfd8b5062ee3bd4fd8b49 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 14 Jan 2021 15:03:34 +0100 Subject: [PATCH] fix(migration): major project iteration bug --- app/tasks/migrate.php | 8 +++++--- src/Appwrite/Migration/Version/V06.php | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/tasks/migrate.php b/app/tasks/migrate.php index c25763ddef..7b9b61cc06 100644 --- a/app/tasks/migrate.php +++ b/app/tasks/migrate.php @@ -38,7 +38,7 @@ $cli $migration = new Version\V06($register->get('db')); //TODO: remove hardcoded version and move to dynamic migration - while ($sum >= 30) { + while ($sum > 0) { foreach ($projects as $project) { try { $migration @@ -61,8 +61,10 @@ $cli $sum = \count($projects); $offset = $offset + $limit; $count = $count + $sum; - - Console::log('Fetched ' . $count . '/' . $consoleDB->getSum() . ' projects...'); + + if ($sum > 0) { + Console::log('Fetched ' . $count . '/' . $consoleDB->getSum() . ' projects...'); + } } Console::success('Data Migration Completed'); diff --git a/src/Appwrite/Migration/Version/V06.php b/src/Appwrite/Migration/Version/V06.php index 46798b315f..f533135446 100644 --- a/src/Appwrite/Migration/Version/V06.php +++ b/src/Appwrite/Migration/Version/V06.php @@ -12,15 +12,14 @@ class V06 extends Migration { public function execute(): void { - Console::log('I got nothing to do. Yet.'); + $project = $this->project; + Console::log('Migrating project: ' . $project->getAttribute('name') . ' (' . $project->getId() . ')'); $this->forEachDocument([$this, 'fixDocument']); } protected function fixDocument(Document $document) { - $providers = Config::getParam('providers'); - switch ($document->getAttribute('$collection')) { case Database::SYSTEM_COLLECTION_USERS: if ($document->getAttribute('password-update', null)) { @@ -28,21 +27,23 @@ class V06 extends Migration ->setAttribute('passwordUpdate', $document->getAttribute('password-update', $document->getAttribute('passwordUpdate', ''))) ->removeAttribute('password-update'); } - if($document->getAttribute('prefs', null)) { + if ($document->getAttribute('prefs', null)) { //TODO: take care of filter ['json'] } break; case Database::SYSTEM_COLLECTION_WEBHOOKS: - if($document->getAttribute('httpPass', null)) { + if ($document->getAttribute('httpPass', null)) { //TODO: take care of filter ['encrypt'] } break; case Database::SYSTEM_COLLECTION_TASKS: - if($document->getAttribute('httpPass', null)) { + if ($document->getAttribute('httpPass', null)) { //TODO: take care of filter ['encrypt'] } break; case Database::SYSTEM_COLLECTION_PROJECTS: + $providers = Config::getParam('providers'); + foreach ($providers as $key => $provider) { if ($document->getAttribute('usersOauth' . \ucfirst($key) . 'Secret', null)) { //TODO: take care of filter ['encrypt]