From 5d49ac80b43a34b48f1455a198dc87bc967fb796 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Tue, 23 Jan 2024 10:21:55 +0000 Subject: [PATCH] Add create targets migrations --- src/Appwrite/Migration/Version/V20.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index d8a333ccf4..e88f42062b 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -118,6 +118,25 @@ class V20 extends Migration case 'schedules': $document->setAttribute('resourceCollection', 'functions'); break; + case 'users': + if ($document->getAttribute('email', '') !== '') { + $document->setAttribute('targets', [ + 'userId' => $document->getId(), + 'userInternalId' => $document->getInternalId(), + 'providerType' => MESSAGE_TYPE_EMAIL, + 'identifier' => $document->getAttribute('email'), + ]); + } + + if ($document->getAttribute('phone', '') !== '') { + $document->setAttribute('targets', [ + 'userId' => $document->getId(), + 'userInternalId' => $document->getInternalId(), + 'providerType' => MESSAGE_TYPE_SMS, + 'identifier' => $document->getAttribute('phone'), + ]); + } + break; } return $document; }