From 3ef9d19cf7687834768bf18a9ad21e33e1ced501 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 18 Apr 2025 17:48:56 +0530 Subject: [PATCH 1/4] fix added null check for the createdAt and upatedAt for the index creation for backward compatibility --- src/Migration/Resources/Database/Index.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Migration/Resources/Database/Index.php b/src/Migration/Resources/Database/Index.php index a2f0f3a7..9509c5f5 100644 --- a/src/Migration/Resources/Database/Index.php +++ b/src/Migration/Resources/Database/Index.php @@ -7,12 +7,16 @@ class Index extends Resource { + protected static string $timeStampFormatDb = 'Y-m-d H:i:s.v'; public const TYPE_UNIQUE = 'unique'; public const TYPE_FULLTEXT = 'fulltext'; public const TYPE_KEY = 'key'; + protected string $createdAt; + protected string $updatedAt; + /** * @param string $id * @param string $key @@ -21,7 +25,7 @@ class Index extends Resource * @param array $attributes * @param array $lengths * @param array $orders - * @param string $createdAt + * @param string|null $createdAt * @param string $updatedAt */ public function __construct( @@ -32,10 +36,14 @@ public function __construct( private readonly array $attributes = [], private readonly array $lengths = [], private readonly array $orders = [], - protected string $createdAt = '', - protected string $updatedAt = '', + ?string $createdAt = null, + ?string $updatedAt = null, ) { $this->id = $id; + $date = new \DateTime(); + $now = $date->format(self::$timeStampFormatDb); + $this->$createdAt = $createdAt ?? $now; + $this->$updatedAt = $updatedAt ?? $now; } /** From 67edeaae33c72c6a183669c443d07dfa8601d487 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 21 Apr 2025 09:57:17 +0530 Subject: [PATCH 2/4] empty commit --- src/Migration/Resources/Database/Index.php | 14 +++----------- src/Migration/Sources/Appwrite.php | 5 +++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Migration/Resources/Database/Index.php b/src/Migration/Resources/Database/Index.php index 9509c5f5..f674bed4 100644 --- a/src/Migration/Resources/Database/Index.php +++ b/src/Migration/Resources/Database/Index.php @@ -7,16 +7,12 @@ class Index extends Resource { - protected static string $timeStampFormatDb = 'Y-m-d H:i:s.v'; public const TYPE_UNIQUE = 'unique'; public const TYPE_FULLTEXT = 'fulltext'; public const TYPE_KEY = 'key'; - protected string $createdAt; - protected string $updatedAt; - /** * @param string $id * @param string $key @@ -25,7 +21,7 @@ class Index extends Resource * @param array $attributes * @param array $lengths * @param array $orders - * @param string|null $createdAt + * @param string $createdAt * @param string $updatedAt */ public function __construct( @@ -36,14 +32,10 @@ public function __construct( private readonly array $attributes = [], private readonly array $lengths = [], private readonly array $orders = [], - ?string $createdAt = null, - ?string $updatedAt = null, + protected string $createdAt = "", + protected string $updatedAt = "", ) { $this->id = $id; - $date = new \DateTime(); - $now = $date->format(self::$timeStampFormatDb); - $this->$createdAt = $createdAt ?? $now; - $this->$updatedAt = $updatedAt ?? $now; } /** diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index 35507c8c..ac32f922 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -11,6 +11,7 @@ use Appwrite\Services\Teams; use Appwrite\Services\Users; use Utopia\Database\Database as UtopiaDatabase; +use Utopia\Database\DateTime as DbDateTime; use Utopia\Migration\Exception; use Utopia\Migration\Resource; use Utopia\Migration\Resources\Auth\Hash; @@ -921,8 +922,8 @@ private function exportIndexes(int $batchSize): void $index['attributes'], [], $index['orders'], - $index['$createdAt'], - $index['$updatedAt'], + $index['$createdAt'] = empty($index['$createdAt']) ? DbDateTime::now() : $index['$createdAt'], + $index['$updatedAt'] = empty($index['$updatedAt']) ? DbDateTime::now() : $index['$updatedAt'], ); } From 89eed2bca1b70fbc4928f6fc2417e322bf8e9be7 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 21 Apr 2025 09:59:29 +0530 Subject: [PATCH 3/4] empty commit --- src/Migration/Resources/Database/Index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Migration/Resources/Database/Index.php b/src/Migration/Resources/Database/Index.php index f674bed4..a2f0f3a7 100644 --- a/src/Migration/Resources/Database/Index.php +++ b/src/Migration/Resources/Database/Index.php @@ -32,8 +32,8 @@ public function __construct( private readonly array $attributes = [], private readonly array $lengths = [], private readonly array $orders = [], - protected string $createdAt = "", - protected string $updatedAt = "", + protected string $createdAt = '', + protected string $updatedAt = '', ) { $this->id = $id; } From 235fe53397f01f35fb1642adc0f81b4da5c912fc Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 21 Apr 2025 10:14:38 +0530 Subject: [PATCH 4/4] changed "DbDateTime" to "UtopiaDateTime" --- src/Migration/Sources/Appwrite.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index ac32f922..204413df 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -11,7 +11,7 @@ use Appwrite\Services\Teams; use Appwrite\Services\Users; use Utopia\Database\Database as UtopiaDatabase; -use Utopia\Database\DateTime as DbDateTime; +use Utopia\Database\DateTime as UtopiaDateTime; use Utopia\Migration\Exception; use Utopia\Migration\Resource; use Utopia\Migration\Resources\Auth\Hash; @@ -922,8 +922,8 @@ private function exportIndexes(int $batchSize): void $index['attributes'], [], $index['orders'], - $index['$createdAt'] = empty($index['$createdAt']) ? DbDateTime::now() : $index['$createdAt'], - $index['$updatedAt'] = empty($index['$updatedAt']) ? DbDateTime::now() : $index['$updatedAt'], + $index['$createdAt'] = empty($index['$createdAt']) ? UtopiaDateTime::now() : $index['$createdAt'], + $index['$updatedAt'] = empty($index['$updatedAt']) ? UtopiaDateTime::now() : $index['$updatedAt'], ); }