diff --git a/composer.json b/composer.json index a52b23a9..7cb93cdb 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.77", "utopia-php/storage": "2.*", "utopia-php/dsn": "0.2.*", "halaxa/json-machine": "^1.2" diff --git a/composer.lock b/composer.lock index 5878a445..5a9224b0 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": "38981f8df096cfbc9dd34487643b7ed6", + "content-hash": "ae396ad0e75429f13de6f2891f3cfae3", "packages": [ { "name": "appwrite/appwrite", @@ -2230,22 +2230,23 @@ }, { "name": "utopia-php/database", - "version": "5.3.22", + "version": "dev-big-init", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "d765945da6b3141852014b2f96ecf1fe7e3d6ba7" + "reference": "ee8895a3ae835978fa4eb143619e4950e7001648" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/d765945da6b3141852014b2f96ecf1fe7e3d6ba7", - "reference": "d765945da6b3141852014b2f96ecf1fe7e3d6ba7", + "url": "https://api.github.com/repos/utopia-php/database/zipball/ee8895a3ae835978fa4eb143619e4950e7001648", + "reference": "ee8895a3ae835978fa4eb143619e4950e7001648", "shasum": "" }, "require": { "ext-mbstring": "*", "ext-mongodb": "*", "ext-pdo": "*", + "ext-redis": "*", "php": ">=8.4", "utopia-php/cache": "1.*", "utopia-php/console": "0.1.*", @@ -2283,9 +2284,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/5.3.22" + "source": "https://github.com/utopia-php/database/tree/big-init" }, - "time": "2026-04-20T07:12:46+00:00" + "time": "2026-05-05T13:27:52+00:00" }, { "name": "utopia-php/dsn", @@ -4947,9 +4948,18 @@ "time": "2025-12-27T19:49:13+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-big-init", + "alias": "5.77", + "alias_normalized": "5.77.0.0" + } + ], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 41023b1a..41edaa6e 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -696,6 +696,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..a6d90450 --- /dev/null +++ b/src/Migration/Resources/Database/Columns/BigInt.php @@ -0,0 +1,108 @@ + $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, + signed: $array['signed'] ?? true, + 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 738a8093..48dc03d9 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; @@ -2384,6 +2385,19 @@ 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, + signed: $column['signed'] ?? true, + 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 0595b956..762ed2fb 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 2b0c9bfe..1a8d70cb 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',