From 151e2794a015ce02813f04609d90f945c96bbd34 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Tue, 9 Sep 2025 12:18:22 +0530 Subject: [PATCH 1/4] added spatial type --- src/Migration/Resources/Database/Column.php | 4 + .../Resources/Database/Columns/Line.php | 74 +++++++++++++++++++ .../Resources/Database/Columns/Point.php | 74 +++++++++++++++++++ .../Resources/Database/Columns/Polygon.php | 74 +++++++++++++++++++ src/Migration/Sources/Appwrite.php | 30 ++++++++ 5 files changed, 256 insertions(+) create mode 100644 src/Migration/Resources/Database/Columns/Line.php create mode 100644 src/Migration/Resources/Database/Columns/Point.php create mode 100644 src/Migration/Resources/Database/Columns/Polygon.php diff --git a/src/Migration/Resources/Database/Column.php b/src/Migration/Resources/Database/Column.php index 32279d3f..e064a404 100644 --- a/src/Migration/Resources/Database/Column.php +++ b/src/Migration/Resources/Database/Column.php @@ -18,6 +18,10 @@ abstract class Column extends Resource public const TYPE_URL = 'url'; public const TYPE_RELATIONSHIP = 'relationship'; + public const TYPE_POINT = 'point'; + public const TYPE_LINE = 'linestring'; + public const TYPE_POLYGON = 'polygon'; + /** * @param string $key * @param Table $table diff --git a/src/Migration/Resources/Database/Columns/Line.php b/src/Migration/Resources/Database/Columns/Line.php new file mode 100644 index 00000000..bdec8b09 --- /dev/null +++ b/src/Migration/Resources/Database/Columns/Line.php @@ -0,0 +1,74 @@ + + * }, + * table?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * rowSecurity: bool, + * permissions: ?array + * }, + * required: bool, + * default: ?array, + * 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'], + createdAt: $array['createdAt'] ?? '', + updatedAt: $array['updatedAt'] ?? '', + ); + } + + public function getType(): string + { + return Column::TYPE_LINE; + } +} diff --git a/src/Migration/Resources/Database/Columns/Point.php b/src/Migration/Resources/Database/Columns/Point.php new file mode 100644 index 00000000..cd4dfaba --- /dev/null +++ b/src/Migration/Resources/Database/Columns/Point.php @@ -0,0 +1,74 @@ + + * }, + * table?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * rowSecurity: bool, + * permissions: ?array + * }, + * required: bool, + * default: ?array, + * 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'], + createdAt: $array['createdAt'] ?? '', + updatedAt: $array['updatedAt'] ?? '', + ); + } + + public function getType(): string + { + return Column::TYPE_POINT; + } +} diff --git a/src/Migration/Resources/Database/Columns/Polygon.php b/src/Migration/Resources/Database/Columns/Polygon.php new file mode 100644 index 00000000..5496e2d6 --- /dev/null +++ b/src/Migration/Resources/Database/Columns/Polygon.php @@ -0,0 +1,74 @@ + + * }, + * table?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * rowSecurity: bool, + * permissions: ?array + * }, + * required: bool, + * default: ?array, + * 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'], + createdAt: $array['createdAt'] ?? '', + updatedAt: $array['updatedAt'] ?? '', + ); + } + + public function getType(): string + { + return Column::TYPE_POLYGON; + } +} diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index 2b154746..9acef82c 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -26,6 +26,9 @@ use Utopia\Migration\Resources\Database\Columns\Enum; use Utopia\Migration\Resources\Database\Columns\Integer; use Utopia\Migration\Resources\Database\Columns\IP; +use Utopia\Migration\Resources\Database\Columns\Line; +use Utopia\Migration\Resources\Database\Columns\Point; +use Utopia\Migration\Resources\Database\Columns\Polygon; use Utopia\Migration\Resources\Database\Columns\Relationship; use Utopia\Migration\Resources\Database\Columns\Text; use Utopia\Migration\Resources\Database\Columns\URL; @@ -945,6 +948,33 @@ private function exportColumns(int $batchSize): void updatedAt: $column['$updatedAt'] ?? '', ); break; + case Column::TYPE_POINT: + $col = new Point( + $column['key'], + $table, + required: $column['required'], + default: $column['default'], + createdAt: $column['$createdAt'] ?? '', + updatedAt: $column['$updatedAt'] ?? '', + ); + case Column::TYPE_LINE: + $col = new Line( + $column['key'], + $table, + required: $column['required'], + default: $column['default'], + createdAt: $column['$createdAt'] ?? '', + updatedAt: $column['$updatedAt'] ?? '', + ); + case Column::TYPE_POLYGON: + $col = new Polygon( + $column['key'], + $table, + required: $column['required'], + default: $column['default'], + createdAt: $column['$createdAt'] ?? '', + updatedAt: $column['$updatedAt'] ?? '', + ); } if (!isset($col)) { From d0fd99e538485ea8134a94c0f44a2d696541948d Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Tue, 9 Sep 2025 12:28:41 +0530 Subject: [PATCH 2/4] added spatial type --- composer.lock | 66 +++++++++---------- src/Migration/Destinations/Appwrite.php | 3 + src/Migration/Resources/Database/Database.php | 3 + src/Migration/Sources/Appwrite.php | 3 + 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/composer.lock b/composer.lock index ec8fbd10..f89d1245 100644 --- a/composer.lock +++ b/composer.lock @@ -50,25 +50,25 @@ }, { "name": "brick/math", - "version": "0.13.1", + "version": "0.14.0", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04" + "reference": "113a8ee2656b882d4c3164fa31aa6e12cbb7aaa2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/fc7ed316430118cc7836bf45faff18d5dfc8de04", - "reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04", + "url": "https://api.github.com/repos/brick/math/zipball/113a8ee2656b882d4c3164fa31aa6e12cbb7aaa2", + "reference": "113a8ee2656b882d4c3164fa31aa6e12cbb7aaa2", "shasum": "" }, "require": { - "php": "^8.1" + "php": "^8.2" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^10.1", - "vimeo/psalm": "6.8.8" + "phpstan/phpstan": "2.1.22", + "phpunit/phpunit": "^11.5" }, "type": "library", "autoload": { @@ -98,7 +98,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.13.1" + "source": "https://github.com/brick/math/tree/0.14.0" }, "funding": [ { @@ -106,7 +106,7 @@ "type": "github" } ], - "time": "2025-03-29T13:50:30+00:00" + "time": "2025-08-29T12:40:03+00:00" }, { "name": "composer/semver", @@ -378,16 +378,16 @@ }, { "name": "open-telemetry/api", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/api.git", - "reference": "b3a9286f9c1c8247c83493c5b1fa475cd0cec7f7" + "reference": "7692075f486c14d8cfd37fba98a08a5667f089e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/b3a9286f9c1c8247c83493c5b1fa475cd0cec7f7", - "reference": "b3a9286f9c1c8247c83493c5b1fa475cd0cec7f7", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/7692075f486c14d8cfd37fba98a08a5667f089e5", + "reference": "7692075f486c14d8cfd37fba98a08a5667f089e5", "shasum": "" }, "require": { @@ -444,7 +444,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-06-19T23:36:51+00:00" + "time": "2025-08-07T23:07:38+00:00" }, { "name": "open-telemetry/context", @@ -634,22 +634,22 @@ }, { "name": "open-telemetry/sdk", - "version": "1.7.0", + "version": "1.7.1", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/sdk.git", - "reference": "86287cf30fd6549444d7b8f7d8758d92e24086ac" + "reference": "52690d4b37ae4f091af773eef3c238ed2bc0aa06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/86287cf30fd6549444d7b8f7d8758d92e24086ac", - "reference": "86287cf30fd6549444d7b8f7d8758d92e24086ac", + "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/52690d4b37ae4f091af773eef3c238ed2bc0aa06", + "reference": "52690d4b37ae4f091af773eef3c238ed2bc0aa06", "shasum": "" }, "require": { "ext-json": "*", "nyholm/psr7-server": "^1.1", - "open-telemetry/api": "~1.4.0", + "open-telemetry/api": "^1.4", "open-telemetry/context": "^1.0", "open-telemetry/sem-conv": "^1.0", "php": "^8.1", @@ -727,7 +727,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-08-06T03:07:06+00:00" + "time": "2025-09-05T07:17:06+00:00" }, { "name": "open-telemetry/sem-conv", @@ -1206,20 +1206,20 @@ }, { "name": "ramsey/uuid", - "version": "4.9.0", + "version": "4.9.1", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "4e0e23cc785f0724a0e838279a9eb03f28b092a0" + "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/4e0e23cc785f0724a0e838279a9eb03f28b092a0", - "reference": "4e0e23cc785f0724a0e838279a9eb03f28b092a0", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/81f941f6f729b1e3ceea61d9d014f8b6c6800440", + "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13", + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" }, @@ -1278,9 +1278,9 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.9.0" + "source": "https://github.com/ramsey/uuid/tree/4.9.1" }, - "time": "2025-06-25T14:20:11+00:00" + "time": "2025-09-04T20:59:21+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2110,16 +2110,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.24", + "version": "0.33.27", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "5112b1023342163e3fbedec99f38fc32c8700aa0" + "reference": "d9d10a895e85c8c7675220347cc6109db9d3bd37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/5112b1023342163e3fbedec99f38fc32c8700aa0", - "reference": "5112b1023342163e3fbedec99f38fc32c8700aa0", + "url": "https://api.github.com/repos/utopia-php/http/zipball/d9d10a895e85c8c7675220347cc6109db9d3bd37", + "reference": "d9d10a895e85c8c7675220347cc6109db9d3bd37", "shasum": "" }, "require": { @@ -2151,9 +2151,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.24" + "source": "https://github.com/utopia-php/http/tree/0.33.27" }, - "time": "2025-09-04T04:18:39+00:00" + "time": "2025-09-07T18:40:53+00:00" }, { "name": "utopia-php/pools", diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 8425adc5..ac3a6f5d 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -439,6 +439,9 @@ protected function createColumn(Column $resource): bool Column::TYPE_IP, Column::TYPE_EMAIL, Column::TYPE_URL, + Column::TYPE_POINT => UtopiaDatabase::VAR_POINT, + Column::TYPE_LINE => UtopiaDatabase::VAR_LINESTRING, + Column::TYPE_POLYGON => UtopiaDatabase::VAR_POLYGON, Column::TYPE_ENUM => UtopiaDatabase::VAR_STRING, default => throw new \Exception('Invalid resource type '.$resource->getType()), }; diff --git a/src/Migration/Resources/Database/Database.php b/src/Migration/Resources/Database/Database.php index 48254630..06882b21 100644 --- a/src/Migration/Resources/Database/Database.php +++ b/src/Migration/Resources/Database/Database.php @@ -12,6 +12,9 @@ const TYPE_OBJECT = 'object'; const TYPE_ARRAY = 'array'; const TYPE_NULL = 'null'; +const TYPE_POINT = 'point'; +const TYPE_LINE = 'linestring'; +const TYPE_POLYGON = 'polygon'; class Database extends Resource { diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index 9acef82c..27cc056f 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -957,6 +957,7 @@ private function exportColumns(int $batchSize): void createdAt: $column['$createdAt'] ?? '', updatedAt: $column['$updatedAt'] ?? '', ); + break; case Column::TYPE_LINE: $col = new Line( $column['key'], @@ -966,6 +967,7 @@ private function exportColumns(int $batchSize): void createdAt: $column['$createdAt'] ?? '', updatedAt: $column['$updatedAt'] ?? '', ); + break; case Column::TYPE_POLYGON: $col = new Polygon( $column['key'], @@ -975,6 +977,7 @@ private function exportColumns(int $batchSize): void createdAt: $column['$createdAt'] ?? '', updatedAt: $column['$updatedAt'] ?? '', ); + break; } if (!isset($col)) { From 3b36f0901b17beebcb4b8b726926c5b8ecbdc8d8 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Tue, 9 Sep 2025 13:21:24 +0530 Subject: [PATCH 3/4] updated index --- src/Migration/Resources/Database/Index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Migration/Resources/Database/Index.php b/src/Migration/Resources/Database/Index.php index 179e42fe..599672a6 100644 --- a/src/Migration/Resources/Database/Index.php +++ b/src/Migration/Resources/Database/Index.php @@ -13,6 +13,8 @@ class Index extends Resource public const TYPE_KEY = 'key'; + public const TYPE_SPATIAL = 'spatial'; + /** * @param string $id * @param string $key From 3ef02447f1e978aca3e91c20cad8328fc5dca049 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 10 Sep 2025 10:43:12 +0530 Subject: [PATCH 4/4] updated migrations --- src/Migration/Destinations/Appwrite.php | 2 +- src/Migration/Resources/Database/Columns/Line.php | 4 ++-- src/Migration/Resources/Database/Columns/Point.php | 4 ++-- src/Migration/Resources/Database/Columns/Polygon.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index ac3a6f5d..4e38457e 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -439,10 +439,10 @@ protected function createColumn(Column $resource): bool Column::TYPE_IP, Column::TYPE_EMAIL, Column::TYPE_URL, + Column::TYPE_ENUM => UtopiaDatabase::VAR_STRING, Column::TYPE_POINT => UtopiaDatabase::VAR_POINT, Column::TYPE_LINE => UtopiaDatabase::VAR_LINESTRING, Column::TYPE_POLYGON => UtopiaDatabase::VAR_POLYGON, - Column::TYPE_ENUM => UtopiaDatabase::VAR_STRING, default => throw new \Exception('Invalid resource type '.$resource->getType()), }; diff --git a/src/Migration/Resources/Database/Columns/Line.php b/src/Migration/Resources/Database/Columns/Line.php index bdec8b09..08e70a00 100644 --- a/src/Migration/Resources/Database/Columns/Line.php +++ b/src/Migration/Resources/Database/Columns/Line.php @@ -10,8 +10,8 @@ class Line extends Column public function __construct( string $key, Table $table, - bool $required = false, - ?array $default = null, + bool $required = false, + ?array $default = null, string $createdAt = '', string $updatedAt = '' ) { diff --git a/src/Migration/Resources/Database/Columns/Point.php b/src/Migration/Resources/Database/Columns/Point.php index cd4dfaba..423545fb 100644 --- a/src/Migration/Resources/Database/Columns/Point.php +++ b/src/Migration/Resources/Database/Columns/Point.php @@ -10,8 +10,8 @@ class Point extends Column public function __construct( string $key, Table $table, - bool $required = false, - ?array $default = null, + bool $required = false, + ?array $default = null, string $createdAt = '', string $updatedAt = '' ) { diff --git a/src/Migration/Resources/Database/Columns/Polygon.php b/src/Migration/Resources/Database/Columns/Polygon.php index 5496e2d6..b86ee391 100644 --- a/src/Migration/Resources/Database/Columns/Polygon.php +++ b/src/Migration/Resources/Database/Columns/Polygon.php @@ -10,8 +10,8 @@ class Polygon extends Column public function __construct( string $key, Table $table, - bool $required = false, - ?array $default = null, + bool $required = false, + ?array $default = null, string $createdAt = '', string $updatedAt = '' ) {