From 3226182ec82b1668587d04cab7f5fdc1d84fc6bd Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 24 Jan 2024 18:13:36 +0000 Subject: [PATCH] Create the targets in the target collection instead of on the user --- src/Appwrite/Migration/Version/V20.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index e88f42062b..fd2e1f34e8 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -6,6 +6,7 @@ use Appwrite\Migration\Migration; use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Helpers\ID; class V20 extends Migration { @@ -120,21 +121,25 @@ class V20 extends Migration break; case 'users': if ($document->getAttribute('email', '') !== '') { - $document->setAttribute('targets', [ + $target = new Document([ + '$id' => ID::unique(), 'userId' => $document->getId(), 'userInternalId' => $document->getInternalId(), 'providerType' => MESSAGE_TYPE_EMAIL, 'identifier' => $document->getAttribute('email'), ]); + $this->projectDB->createDocument('targets', $target); } if ($document->getAttribute('phone', '') !== '') { - $document->setAttribute('targets', [ + $target = new Document([ + '$id' => ID::unique(), 'userId' => $document->getId(), 'userInternalId' => $document->getInternalId(), 'providerType' => MESSAGE_TYPE_SMS, 'identifier' => $document->getAttribute('phone'), ]); + $this->projectDB->createDocument('targets', $target); } break; }