mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #167 from utopia-php/big-int
feat: add BigInt column type support and update related classes
This commit is contained in:
8 files changed
+149
-13
No files matched your search
+1
-1
@@ -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"
|
||||
|
||||
Generated
+19
-9
@@ -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": {
|
||||
|
||||
@@ -696,6 +696,7 @@ class Appwrite extends Destination
|
||||
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,
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Utopia\Migration\Resources\Database\Columns;
|
||||
|
||||
use Utopia\Migration\Resources\Database\Column;
|
||||
use Utopia\Migration\Resources\Database\Table;
|
||||
|
||||
class BigInt extends Column
|
||||
{
|
||||
public function __construct(
|
||||
string $key,
|
||||
Table $table,
|
||||
bool $required = false,
|
||||
?int $default = null,
|
||||
bool $array = false,
|
||||
?int $min = null,
|
||||
?int $max = null,
|
||||
bool $signed = true,
|
||||
string $createdAt = '',
|
||||
string $updatedAt = ''
|
||||
) {
|
||||
$min ??= PHP_INT_MIN;
|
||||
$max ??= PHP_INT_MAX;
|
||||
$size = 8;
|
||||
|
||||
parent::__construct(
|
||||
$key,
|
||||
$table,
|
||||
size: $size,
|
||||
required: $required,
|
||||
default: $default,
|
||||
array: $array,
|
||||
signed: $signed,
|
||||
formatOptions: [
|
||||
'min' => $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<string>
|
||||
* },
|
||||
* table?: array{
|
||||
* database: array{
|
||||
* id: string,
|
||||
* name: string,
|
||||
* },
|
||||
* name: string,
|
||||
* id: string,
|
||||
* rowSecurity: bool,
|
||||
* permissions: ?array<string>
|
||||
* },
|
||||
* 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'];
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ use Utopia\Migration\Resources\Auth\User;
|
||||
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 @@ class Appwrite extends Source
|
||||
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,
|
||||
|
||||
@@ -301,7 +301,7 @@ class CSV extends Source
|
||||
|
||||
$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 @@ class CSV extends Source
|
||||
'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 @@ class CSV extends Source
|
||||
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,
|
||||
|
||||
@@ -8,6 +8,7 @@ use Utopia\Migration\Resource;
|
||||
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 @@ class NHost extends Source
|
||||
$column['column_default'] = null;
|
||||
}
|
||||
|
||||
return new Integer(
|
||||
return new BigInt(
|
||||
$column['column_name'],
|
||||
$table,
|
||||
required: $column['is_nullable'] === 'NO',
|
||||
|
||||
Reference in new issue
Block a user