mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Create the targets in the target collection instead of on the user
This commit is contained in:
parent
4ce5256c1e
commit
3226182ec8
1 changed files with 7 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue