From e6c986d3fb89ca476badedbd397bb563ecbcafa2 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 2 Mar 2022 08:53:06 +0100 Subject: [PATCH] fix: files migration --- src/Appwrite/Migration/Version/V12.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Appwrite/Migration/Version/V12.php b/src/Appwrite/Migration/Version/V12.php index b65a282871..20522cd501 100644 --- a/src/Appwrite/Migration/Version/V12.php +++ b/src/Appwrite/Migration/Version/V12.php @@ -175,6 +175,29 @@ class V12 extends Migration ])); $this->createCollection('files', 'bucket_1'); + $nextDocument = null; + do { + $documents = $this->projectDB->find('files', limit: $this->limit, cursor: $nextDocument); + $count = count($documents); + \Co\run(function (array $documents) { + foreach ($documents as $document) { + go(function (Document $document) { + $document + ->setAttribute('bucketId', 'default') + ->setAttribute('chunksTotal', 1) + ->setAttribute('chunksUploaded', 1); + $this->projectDB->createDocument('bucket_1', $document); + }, $document); + } + }, $documents); + + if ($count !== $this->limit) { + $nextDocument = null; + } else { + $nextDocument = end($documents); + } + } while (!is_null($nextDocument)); + /** * Rename folder on volumes. */