From c3ea0d670d2fd86893a4f7bafad62f17883a1571 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 30 Mar 2026 14:27:23 +0530 Subject: [PATCH 1/3] feat: add BigInt column type support and update related classes --- composer.json | 2 +- composer.lock | 117 ++++++------------ src/Migration/Destinations/Appwrite.php | 1 + src/Migration/Resources/Database/Column.php | 1 + .../Resources/Database/Columns/BigInt.php | 107 ++++++++++++++++ src/Migration/Sources/Appwrite.php | 13 ++ src/Migration/Sources/CSV.php | 5 +- src/Migration/Sources/NHost.php | 3 +- 8 files changed, 168 insertions(+), 81 deletions(-) create mode 100644 src/Migration/Resources/Database/Columns/BigInt.php diff --git a/composer.json b/composer.json index 5585f2a5..a3c194e9 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "ext-curl": "*", "ext-openssl": "*", "appwrite/appwrite": "19.*", - "utopia-php/database": "5.*", + "utopia-php/database": "dev-big-init as 5.4", "utopia-php/storage": "1.0.*", "utopia-php/dsn": "0.2.*", "halaxa/json-machine": "^1.2" diff --git a/composer.lock b/composer.lock index 17d14221..6a9d2072 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "37980b9001fbbd4f213f3102c1332727", + "content-hash": "16a5b9e9382b5fa55ea40c8ec5a9cc00", "packages": [ { "name": "appwrite/appwrite", @@ -2181,17 +2181,17 @@ "time": "2026-01-28T10:55:44+00:00" }, { - "name": "utopia-php/compression", - "version": "0.1.3", + "name": "utopia-php/console", + "version": "0.1.1", "source": { "type": "git", - "url": "https://github.com/utopia-php/compression.git", - "reference": "66f093557ba66d98245e562036182016c7dcfe8a" + "url": "https://github.com/utopia-php/console.git", + "reference": "d298e43960780e6d76e66de1228c75dc81220e3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/compression/zipball/66f093557ba66d98245e562036182016c7dcfe8a", - "reference": "66f093557ba66d98245e562036182016c7dcfe8a", + "url": "https://api.github.com/repos/utopia-php/console/zipball/d298e43960780e6d76e66de1228c75dc81220e3e", + "reference": "d298e43960780e6d76e66de1228c75dc81220e3e", "shasum": "" }, "require": { @@ -2199,45 +2199,47 @@ }, "require-dev": { "laravel/pint": "1.2.*", + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.3", - "vimeo/psalm": "4.0.1" + "squizlabs/php_codesniffer": "^3.6", + "swoole/ide-helper": "4.8.8" }, "type": "library", "autoload": { "psr-4": { - "Utopia\\Compression\\": "src/Compression" + "Utopia\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "A simple Compression library to handle file compression", + "description": "Console helpers for logging, prompting, and executing commands", "keywords": [ - "compression", - "framework", + "cli", + "console", "php", - "upf", + "terminal", "utopia" ], "support": { - "issues": "https://github.com/utopia-php/compression/issues", - "source": "https://github.com/utopia-php/compression/tree/0.1.3" + "issues": "https://github.com/utopia-php/console/issues", + "source": "https://github.com/utopia-php/console/tree/0.1.1" }, - "time": "2025-01-15T15:15:51+00:00" + "time": "2026-02-10T10:20:29+00:00" }, { "name": "utopia-php/database", - "version": "5.2.1", + "version": "dev-big-init", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "adfdf201144353a1d2ce14bb197ab746079894e0" + "reference": "ef5c77972a95129eb929cce6c8f7c674db930ec9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/adfdf201144353a1d2ce14bb197ab746079894e0", - "reference": "adfdf201144353a1d2ce14bb197ab746079894e0", + "url": "https://api.github.com/repos/utopia-php/database/zipball/ef5c77972a95129eb929cce6c8f7c674db930ec9", + "reference": "ef5c77972a95129eb929cce6c8f7c674db930ec9", "shasum": "" }, "require": { @@ -2246,9 +2248,10 @@ "ext-pdo": "*", "php": ">=8.4", "utopia-php/cache": "1.*", - "utopia-php/framework": "0.33.*", + "utopia-php/console": "0.1.*", "utopia-php/mongo": "1.*", - "utopia-php/pools": "1.*" + "utopia-php/pools": "1.*", + "utopia-php/validators": "0.2.*" }, "require-dev": { "fakerphp/faker": "1.23.*", @@ -2258,7 +2261,7 @@ "phpunit/phpunit": "9.*", "rregeer/phpunit-coverage-check": "0.3.*", "swoole/ide-helper": "5.1.3", - "utopia-php/cli": "0.14.*" + "utopia-php/cli": "0.22.*" }, "type": "library", "autoload": { @@ -2280,9 +2283,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/5.2.1" + "source": "https://github.com/utopia-php/database/tree/big-init" }, - "time": "2026-02-16T11:01:13+00:00" + "time": "2026-03-30T06:31:05+00:00" }, { "name": "utopia-php/dsn", @@ -2331,55 +2334,6 @@ }, "time": "2024-05-07T02:01:25+00:00" }, - { - "name": "utopia-php/framework", - "version": "0.33.39", - "source": { - "type": "git", - "url": "https://github.com/utopia-php/http.git", - "reference": "409a258814d664d3a50fa2f48b6695679334d30b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/409a258814d664d3a50fa2f48b6695679334d30b", - "reference": "409a258814d664d3a50fa2f48b6695679334d30b", - "shasum": "" - }, - "require": { - "php": ">=8.3", - "utopia-php/compression": "0.1.*", - "utopia-php/telemetry": "0.2.*", - "utopia-php/validators": "0.2.*" - }, - "require-dev": { - "laravel/pint": "1.*", - "phpbench/phpbench": "1.*", - "phpstan/phpstan": "1.*", - "phpunit/phpunit": "9.*", - "swoole/ide-helper": "^6.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Utopia\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A simple, light and advanced PHP framework", - "keywords": [ - "framework", - "php", - "upf" - ], - "support": { - "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.39" - }, - "time": "2026-02-11T06:33:42+00:00" - }, { "name": "utopia-php/mongo", "version": "1.0.0", @@ -4995,9 +4949,18 @@ "time": "2025-12-27T19:49:13+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-big-init", + "alias": "5.4", + "alias_normalized": "5.4.0.0" + } + ], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -5008,5 +4971,5 @@ "platform-dev": { "ext-pdo": "*" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.9.0" } diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 0d0e7d64..49cadb72 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -542,6 +542,7 @@ protected function createField(Column|Attribute $resource): bool Column::TYPE_DATETIME => UtopiaDatabase::VAR_DATETIME, Column::TYPE_BOOLEAN => UtopiaDatabase::VAR_BOOLEAN, Column::TYPE_INTEGER => UtopiaDatabase::VAR_INTEGER, + Column::TYPE_BIG_INT => UtopiaDatabase::VAR_BIGINT, Column::TYPE_FLOAT => UtopiaDatabase::VAR_FLOAT, Column::TYPE_RELATIONSHIP => UtopiaDatabase::VAR_RELATIONSHIP, diff --git a/src/Migration/Resources/Database/Column.php b/src/Migration/Resources/Database/Column.php index 45aea6d4..3a3ef4fa 100644 --- a/src/Migration/Resources/Database/Column.php +++ b/src/Migration/Resources/Database/Column.php @@ -14,6 +14,7 @@ abstract class Column extends Resource public const TYPE_LONGTEXT = 'longtext'; public const TYPE_INTEGER = 'integer'; + public const TYPE_BIG_INT = 'bigint'; public const TYPE_FLOAT = 'double'; public const TYPE_BOOLEAN = 'boolean'; public const TYPE_DATETIME = 'datetime'; diff --git a/src/Migration/Resources/Database/Columns/BigInt.php b/src/Migration/Resources/Database/Columns/BigInt.php new file mode 100644 index 00000000..7620e770 --- /dev/null +++ b/src/Migration/Resources/Database/Columns/BigInt.php @@ -0,0 +1,107 @@ + $min, + 'max' => $max, + ], + createdAt: $createdAt, + updatedAt: $updatedAt + ); + } + + /** + * @param array{ + * key: string, + * collection?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * documentSecurity: bool, + * permissions: ?array + * }, + * table?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * rowSecurity: bool, + * permissions: ?array + * }, + * required: bool, + * array: bool, + * default: ?int, + * formatOptions: array{ + * min: ?int, + * max: ?int + * }, + * createdAt: string, + * updatedAt: string, + * } $array + * @return self + */ + public static function fromArray(array $array): self + { + return new self( + $array['key'], + Table::fromArray($array['table'] ?? $array['collection']), + required: $array['required'], + default: $array['default'], + array: $array['array'], + min: $array['formatOptions']['min'] ?? null, + max: $array['formatOptions']['max'] ?? null, + createdAt: $array['createdAt'] ?? '', + updatedAt: $array['updatedAt'] ?? '', + ); + } + + public function getType(): string + { + return Column::TYPE_BIG_INT; + } + + public function getMin(): ?int + { + return (int)$this->formatOptions['min']; + } + + public function getMax(): ?int + { + return (int)$this->formatOptions['max']; + } +} diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index e5e57fa9..db59cc9d 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -24,6 +24,7 @@ use Utopia\Migration\Resources\Database\Attribute; use Utopia\Migration\Resources\Database\Collection; use Utopia\Migration\Resources\Database\Column; +use Utopia\Migration\Resources\Database\Columns\BigInt; use Utopia\Migration\Resources\Database\Columns\Boolean; use Utopia\Migration\Resources\Database\Columns\DateTime; use Utopia\Migration\Resources\Database\Columns\Decimal; @@ -2368,6 +2369,18 @@ public static function getColumn(Table $table, mixed $column): Column updatedAt: $column['$updatedAt'] ?? '', ), + Column::TYPE_BIG_INT => new BigInt( + $column['key'], + $table, + required: $column['required'], + default: $column['default'], + array: $column['array'], + min: $column['min'] ?? null, + max: $column['max'] ?? null, + createdAt: $column['$createdAt'] ?? '', + updatedAt: $column['$updatedAt'] ?? '', + ), + Column::TYPE_FLOAT => new Decimal( $column['key'], $table, diff --git a/src/Migration/Sources/CSV.php b/src/Migration/Sources/CSV.php index 7d02090f..9b580df2 100644 --- a/src/Migration/Sources/CSV.php +++ b/src/Migration/Sources/CSV.php @@ -301,7 +301,7 @@ private function exportRows(int $batchSize): void $parsedData[$key] = array_map(function ($item) use ($type) { return match ($type) { - Column::TYPE_INTEGER => is_numeric($item) ? (int)$item : null, + Column::TYPE_INTEGER,Column::TYPE_BIG_INT => is_numeric($item) ? (int)$item : null, Column::TYPE_FLOAT => is_numeric($item) ? (float)$item : null, Column::TYPE_BOOLEAN => filter_var($item, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE), default => $item, @@ -323,6 +323,7 @@ private function exportRows(int $batchSize): void 'null' => null, // 'null' string is converted to null '' => match ($type) { Column::TYPE_INTEGER, + Column::TYPE_BIG_INT, Column::TYPE_FLOAT, Column::TYPE_BOOLEAN, Column::TYPE_DATETIME, @@ -330,7 +331,7 @@ private function exportRows(int $batchSize): void default => '', // but empty string stays empty string for compatibility }, default => match ($type) { - Column::TYPE_INTEGER => \is_numeric($parsedValue) ? (int)$parsedValue : null, + Column::TYPE_INTEGER, Column::TYPE_BIG_INT => \is_numeric($parsedValue) ? (int)$parsedValue : null, Column::TYPE_FLOAT => \is_numeric($parsedValue) ? (float)$parsedValue : null, Column::TYPE_BOOLEAN => \filter_var( $parsedValue, diff --git a/src/Migration/Sources/NHost.php b/src/Migration/Sources/NHost.php index 4aac49f8..ada1afb5 100644 --- a/src/Migration/Sources/NHost.php +++ b/src/Migration/Sources/NHost.php @@ -8,6 +8,7 @@ use Utopia\Migration\Resources\Auth\Hash; use Utopia\Migration\Resources\Auth\User; use Utopia\Migration\Resources\Database\Column; +use Utopia\Migration\Resources\Database\Columns\BigInt; use Utopia\Migration\Resources\Database\Columns\Boolean; use Utopia\Migration\Resources\Database\Columns\DateTime; use Utopia\Migration\Resources\Database\Columns\Decimal; @@ -679,7 +680,7 @@ private function convertColumn(array $column, Table $table): Column $column['column_default'] = null; } - return new Integer( + return new BigInt( $column['column_name'], $table, required: $column['is_nullable'] === 'NO', From 0357de375a74069a7dedb503be2c83fbd472361c Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k <83803257+ArnabChatterjee20k@users.noreply.github.com> Date: Mon, 30 Mar 2026 15:30:38 +0530 Subject: [PATCH 2/3] Update src/Migration/Resources/Database/Columns/BigInt.php Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/Migration/Resources/Database/Columns/BigInt.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Migration/Resources/Database/Columns/BigInt.php b/src/Migration/Resources/Database/Columns/BigInt.php index 7620e770..9cefeda9 100644 --- a/src/Migration/Resources/Database/Columns/BigInt.php +++ b/src/Migration/Resources/Database/Columns/BigInt.php @@ -85,10 +85,12 @@ public static function fromArray(array $array): self array: $array['array'], min: $array['formatOptions']['min'] ?? null, max: $array['formatOptions']['max'] ?? null, + signed: $array['signed'] ?? true, createdAt: $array['createdAt'] ?? '', updatedAt: $array['updatedAt'] ?? '', ); } + } public function getType(): string { From 9e8708883677661ac568ba41f7a0b79cd6f04253 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 30 Mar 2026 15:33:42 +0530 Subject: [PATCH 3/3] lint --- src/Migration/Resources/Database/Columns/BigInt.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Migration/Resources/Database/Columns/BigInt.php b/src/Migration/Resources/Database/Columns/BigInt.php index 9cefeda9..a6d90450 100644 --- a/src/Migration/Resources/Database/Columns/BigInt.php +++ b/src/Migration/Resources/Database/Columns/BigInt.php @@ -90,7 +90,6 @@ public static function fromArray(array $array): self updatedAt: $array['updatedAt'] ?? '', ); } - } public function getType(): string {