From e70a69812d0cd4ecfb9911e6e8c83d46cb8815a4 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 11 Mar 2026 12:07:11 +0000 Subject: [PATCH] fix: add timestamps and cache invalidation for push target migration --- src/Migration/Destinations/Appwrite.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 4b5130e1c6..05c62470cf 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -1745,8 +1745,13 @@ class Appwrite extends Destination case 'push': $userDoc ??= $this->dbForProject->getDocument('users', $userId); + $createdAt = $this->normalizeDateTime($target['$createdAt'] ?? null); + $updatedAt = $this->normalizeDateTime($target['$updatedAt'] ?? null, $createdAt); + $this->dbForProject->createDocument('targets', new UtopiaDocument([ '$id' => $target['$id'], + '$createdAt' => $createdAt, + '$updatedAt' => $updatedAt, '$permissions' => [ Permission::read(Role::user($userId)), Permission::update(Role::user($userId)), @@ -1901,9 +1906,16 @@ class Appwrite extends Destination Query::isNull('providerInternalId'), ]); + $userIds = []; + foreach ($targets as $target) { $target->setAttribute('providerInternalId', $provider->getSequence()); $this->dbForProject->updateDocument('targets', $target->getId(), $target); + $userIds[$target->getAttribute('userId')] = true; + } + + foreach (array_keys($userIds) as $userId) { + $this->dbForProject->purgeCachedDocument('users', $userId); } }