From d7886c09db692980423eb03fb55eb5f823ca4b0f Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 15 Feb 2026 12:58:28 +0200 Subject: [PATCH 01/10] text type --- src/Migration/Resources/Database/Column.php | 4 + .../Resources/Database/Columns/LongText.php | 97 +++++++++++++++++++ .../Resources/Database/Columns/MediumText.php | 97 +++++++++++++++++++ .../Database/Columns/RegularText.php | 97 +++++++++++++++++++ src/Migration/Sources/Appwrite.php | 41 ++++++++ 5 files changed, 336 insertions(+) create mode 100644 src/Migration/Resources/Database/Columns/LongText.php create mode 100644 src/Migration/Resources/Database/Columns/MediumText.php create mode 100644 src/Migration/Resources/Database/Columns/RegularText.php diff --git a/src/Migration/Resources/Database/Column.php b/src/Migration/Resources/Database/Column.php index e064a40..94c29f2 100644 --- a/src/Migration/Resources/Database/Column.php +++ b/src/Migration/Resources/Database/Column.php @@ -8,6 +8,10 @@ abstract class Column extends Resource { public const TYPE_STRING = 'string'; + public const TYPE_TEXT = 'text'; + public const TYPE_MEDIUMTEXT = 'mediumtext'; + public const TYPE_LONGTEXT = 'longtext'; + public const TYPE_INTEGER = 'integer'; public const TYPE_FLOAT = 'double'; public const TYPE_BOOLEAN = 'boolean'; diff --git a/src/Migration/Resources/Database/Columns/LongText.php b/src/Migration/Resources/Database/Columns/LongText.php new file mode 100644 index 0000000..a54bd2d --- /dev/null +++ b/src/Migration/Resources/Database/Columns/LongText.php @@ -0,0 +1,97 @@ + + * }, + * table?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * rowSecurity: bool, + * permissions: ?array + * }, + * required: bool, + * default: ?string, + * array: bool, + * size: int, + * format: string, + * 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'] ?? null, + array: $array['array'], + size: $array['size'], + format: $array['format'], + createdAt: $array['createdAt'] ?? '', + updatedAt: $array['updatedAt'] ?? '', + ); + } + + public function getType(): string + { + return Column::TYPE_LONGTEXT; + } + + public function getSize(): int + { + return $this->size; + } + + public function getFormat(): string + { + return $this->format; + } +} diff --git a/src/Migration/Resources/Database/Columns/MediumText.php b/src/Migration/Resources/Database/Columns/MediumText.php new file mode 100644 index 0000000..c7fb80f --- /dev/null +++ b/src/Migration/Resources/Database/Columns/MediumText.php @@ -0,0 +1,97 @@ + + * }, + * table?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * rowSecurity: bool, + * permissions: ?array + * }, + * required: bool, + * default: ?string, + * array: bool, + * size: int, + * format: string, + * 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'] ?? null, + array: $array['array'], + size: $array['size'], + format: $array['format'], + createdAt: $array['createdAt'] ?? '', + updatedAt: $array['updatedAt'] ?? '', + ); + } + + public function getType(): string + { + return Column::TYPE_STRING; + } + + public function getSize(): int + { + return $this->size; + } + + public function getFormat(): string + { + return $this->format; + } +} diff --git a/src/Migration/Resources/Database/Columns/RegularText.php b/src/Migration/Resources/Database/Columns/RegularText.php new file mode 100644 index 0000000..71b1f5f --- /dev/null +++ b/src/Migration/Resources/Database/Columns/RegularText.php @@ -0,0 +1,97 @@ + + * }, + * table?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * rowSecurity: bool, + * permissions: ?array + * }, + * required: bool, + * default: ?string, + * array: bool, + * size: int, + * format: string, + * 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'] ?? null, + array: $array['array'], + size: $array['size'], + format: $array['format'], + createdAt: $array['createdAt'] ?? '', + updatedAt: $array['updatedAt'] ?? '', + ); + } + + public function getType(): string + { + return Column::TYPE_TEXT; + } + + public function getSize(): int + { + return $this->size; + } + + public function getFormat(): string + { + return $this->format; + } +} diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index d07688a..6d24bb1 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -28,8 +28,10 @@ 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\MediumText; use Utopia\Migration\Resources\Database\Columns\Point; use Utopia\Migration\Resources\Database\Columns\Polygon; +use Utopia\Migration\Resources\Database\Columns\RegularText; use Utopia\Migration\Resources\Database\Columns\Relationship; use Utopia\Migration\Resources\Database\Columns\Text; use Utopia\Migration\Resources\Database\Columns\URL; @@ -1090,6 +1092,45 @@ private function exportColumns(int $batchSize): void updatedAt: $column['$updatedAt'] ?? '', ); break; + + case Column::TYPE_TEXT: + $col = new RegularText( + $column['key'], + $table, + required: $column['required'], + default: $column['default'], + array: $column['array'], + size: $column['size'] ?? 65535, + createdAt: $column['$createdAt'] ?? '', + updatedAt: $column['$updatedAt'] ?? '', + ); + break; + + case Column::TYPE_MEDIUMTEXT: + $col = new MediumText( + $column['key'], + $table, + required: $column['required'], + default: $column['default'], + array: $column['array'], + size: $column['size'] ?? 16777215, + createdAt: $column['$createdAt'] ?? '', + updatedAt: $column['$updatedAt'] ?? '', + ); + break; + + case Column::TYPE_LONGTEXT: + $col = new MediumText( + $column['key'], + $table, + required: $column['required'], + default: $column['default'], + array: $column['array'], + size: $column['size'] ?? 2147483647, + createdAt: $column['$createdAt'] ?? '', + updatedAt: $column['$updatedAt'] ?? '', + ); + break; } if (!isset($col)) { From f9e2c7b17e101a82f01795460d64e7f26a574993 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 15 Feb 2026 13:02:56 +0200 Subject: [PATCH 02/10] destination --- src/Migration/Destinations/Appwrite.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index e5a13f7..823739f 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -470,6 +470,9 @@ protected function createColumn(Column $resource): bool Column::TYPE_POINT => UtopiaDatabase::VAR_POINT, Column::TYPE_LINE => UtopiaDatabase::VAR_LINESTRING, Column::TYPE_POLYGON => UtopiaDatabase::VAR_POLYGON, + Column::TYPE_TEXT => UtopiaDatabase::VAR_TEXT, + Column::TYPE_MEDIUMTEXT => UtopiaDatabase::VAR_MEDIUMTEXT, + Column::TYPE_LONGTEXT => UtopiaDatabase::VAR_LONGTEXT, default => throw new \Exception('Invalid resource type '.$resource->getType()), }; From 481539d4fcf998f8d5f1ed3871c42318058c4b40 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 15 Feb 2026 13:19:13 +0200 Subject: [PATCH 03/10] typo --- src/Migration/Resources/Database/Columns/LongText.php | 2 +- src/Migration/Resources/Database/Columns/MediumText.php | 4 ++-- src/Migration/Resources/Database/Columns/RegularText.php | 2 +- src/Migration/Sources/Appwrite.php | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Migration/Resources/Database/Columns/LongText.php b/src/Migration/Resources/Database/Columns/LongText.php index a54bd2d..7f6230c 100644 --- a/src/Migration/Resources/Database/Columns/LongText.php +++ b/src/Migration/Resources/Database/Columns/LongText.php @@ -14,7 +14,7 @@ public function __construct( bool $required = false, ?string $default = null, bool $array = false, - int $size = Database::LENGTH_KEY, + int $size = 2147483647, string $format = '', string $createdAt = '', string $updatedAt = '' diff --git a/src/Migration/Resources/Database/Columns/MediumText.php b/src/Migration/Resources/Database/Columns/MediumText.php index c7fb80f..35acc31 100644 --- a/src/Migration/Resources/Database/Columns/MediumText.php +++ b/src/Migration/Resources/Database/Columns/MediumText.php @@ -14,7 +14,7 @@ public function __construct( bool $required = false, ?string $default = null, bool $array = false, - int $size = Database::LENGTH_KEY, + int $size = 16777215, string $format = '', string $createdAt = '', string $updatedAt = '' @@ -82,7 +82,7 @@ public static function fromArray(array $array): self public function getType(): string { - return Column::TYPE_STRING; + return Column::TYPE_MEDIUMTEXT; } public function getSize(): int diff --git a/src/Migration/Resources/Database/Columns/RegularText.php b/src/Migration/Resources/Database/Columns/RegularText.php index 71b1f5f..9ae55b1 100644 --- a/src/Migration/Resources/Database/Columns/RegularText.php +++ b/src/Migration/Resources/Database/Columns/RegularText.php @@ -14,7 +14,7 @@ public function __construct( bool $required = false, ?string $default = null, bool $array = false, - int $size = Database::LENGTH_KEY, + int $size = 65535, string $format = '', string $createdAt = '', string $updatedAt = '' diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index 6d24bb1..c8624fb 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -28,6 +28,7 @@ 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\LongText; use Utopia\Migration\Resources\Database\Columns\MediumText; use Utopia\Migration\Resources\Database\Columns\Point; use Utopia\Migration\Resources\Database\Columns\Polygon; @@ -1120,7 +1121,7 @@ private function exportColumns(int $batchSize): void break; case Column::TYPE_LONGTEXT: - $col = new MediumText( + $col = new LongText( $column['key'], $table, required: $column['required'], From bf3074ef3bb39916b077d75b9b9f28630f05f98d Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 15 Feb 2026 13:51:21 +0200 Subject: [PATCH 04/10] formatting --- tests/Migration/E2E/Sources/NHostTest.php | 3 ++- tests/Migration/E2E/Sources/SupabaseTest.php | 3 ++- tests/Migration/Unit/General/CSVTest.php | 15 ++++++++++----- tests/Migration/Unit/General/TransferTest.php | 6 ++++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/Migration/E2E/Sources/NHostTest.php b/tests/Migration/E2E/Sources/NHostTest.php index ca4d9f3..d269ad0 100644 --- a/tests/Migration/E2E/Sources/NHostTest.php +++ b/tests/Migration/E2E/Sources/NHostTest.php @@ -109,7 +109,8 @@ public function testRunTransfer($state) { $this->transfer->run( $this->source->getSupportedResources(), - function () {} + function () { + } ); $this->assertCount(0, $this->transfer->getReport('error')); diff --git a/tests/Migration/E2E/Sources/SupabaseTest.php b/tests/Migration/E2E/Sources/SupabaseTest.php index 2ce0397..c41f063 100644 --- a/tests/Migration/E2E/Sources/SupabaseTest.php +++ b/tests/Migration/E2E/Sources/SupabaseTest.php @@ -89,7 +89,8 @@ public function testRunTransfer($state) { $this->transfer->run( $this->source->getSupportedResources(), - function () {} + function () { + } ); $this->assertCount(0, $this->transfer->getReport('error')); diff --git a/tests/Migration/Unit/General/CSVTest.php b/tests/Migration/Unit/General/CSVTest.php index 530a596..e4fd3ec 100644 --- a/tests/Migration/Unit/General/CSVTest.php +++ b/tests/Migration/Unit/General/CSVTest.php @@ -169,7 +169,8 @@ public function testCSVExportWithSpecialCharacters() 'mixed_field' => 'Text with "quotes", commas, and\nnewlines' ]); - $csvDestination->testableImport([$row], function ($resources) {}); + $csvDestination->testableImport([$row], function ($resources) { + }); $csvDestination->shutdown(); $csvFile = $csvDestination->getLocalRoot() . '/test_db_test_table_id.csv'; @@ -215,7 +216,8 @@ public function testCSVExportWithArrays() 'nested' => [['id' => 1], ['id' => 2]] ]); - $csvDestination->testableImport([$row], function ($resources) {}); + $csvDestination->testableImport([$row], function ($resources) { + }); $csvDestination->shutdown(); $csvFile = $csvDestination->getLocalRoot() . '/test_db_test_table_id.csv'; @@ -262,7 +264,8 @@ public function testCSVExportWithNullValues() 'false_bool' => false ]); - $csvDestination->testableImport([$row], function ($resources) {}); + $csvDestination->testableImport([$row], function ($resources) { + }); $csvDestination->shutdown(); $csvFile = $csvDestination->getLocalRoot() . '/test_db_test_table_id.csv'; @@ -309,7 +312,8 @@ public function testCSVExportWithAllowedAttributes() 'secret' => 'should_not_appear' ]); - $csvDestination->testableImport([$row], function ($resources) {}); + $csvDestination->testableImport([$row], function ($resources) { + }); $csvDestination->shutdown(); $csvFile = $csvDestination->getLocalRoot() . '/test_db_test_table_id.csv'; @@ -365,7 +369,8 @@ public function testCSVExportImportCompatibility() $row = new Row('compat_row', $table, $originalData); $row->setPermissions(['read("user:123")']); - $csvDestination->testableImport([$row], function ($resources) {}); + $csvDestination->testableImport([$row], function ($resources) { + }); $csvDestination->shutdown(); // Verify the exported CSV can be parsed by PHP's built-in CSV functions diff --git a/tests/Migration/Unit/General/TransferTest.php b/tests/Migration/Unit/General/TransferTest.php index 9a14439..bf21f84 100644 --- a/tests/Migration/Unit/General/TransferTest.php +++ b/tests/Migration/Unit/General/TransferTest.php @@ -36,7 +36,8 @@ public function testRootResourceId(): void * Make sure we can't create a transfer with multiple root resources when supplying a rootResourceId */ try { - $this->transfer->run([Resource::TYPE_USER, Resource::TYPE_DATABASE], function () {}, 'rootResourceId'); + $this->transfer->run([Resource::TYPE_USER, Resource::TYPE_DATABASE], function () { + }, 'rootResourceId'); $this->fail('Multiple root resources should not be allowed'); } catch (\Exception $e) { $this->assertSame('Resource type must be set when resource ID is set.', $e->getMessage()); @@ -50,7 +51,8 @@ public function testRootResourceId(): void */ $this->transfer->run( [Resource::TYPE_DATABASE], - function () {}, + function () { + }, 'test', Resource::TYPE_DATABASE ); From 6d92c14ffe289fdb7a5f7a0e1729bc2ed75a8573 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 15 Feb 2026 16:25:53 +0200 Subject: [PATCH 05/10] varchar --- src/Migration/Destinations/Appwrite.php | 1 + src/Migration/Resources/Database/Column.php | 1 + .../Resources/Database/Columns/Varchar.php | 97 +++++++++++++++++++ src/Migration/Sources/Appwrite.php | 14 +++ 4 files changed, 113 insertions(+) create mode 100644 src/Migration/Resources/Database/Columns/Varchar.php diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 823739f..6b730a1 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -471,6 +471,7 @@ protected function createColumn(Column $resource): bool Column::TYPE_LINE => UtopiaDatabase::VAR_LINESTRING, Column::TYPE_POLYGON => UtopiaDatabase::VAR_POLYGON, Column::TYPE_TEXT => UtopiaDatabase::VAR_TEXT, + Column::TYPE_VARCHAR => UtopiaDatabase::VAR_VARCHAR, Column::TYPE_MEDIUMTEXT => UtopiaDatabase::VAR_MEDIUMTEXT, Column::TYPE_LONGTEXT => UtopiaDatabase::VAR_LONGTEXT, default => throw new \Exception('Invalid resource type '.$resource->getType()), diff --git a/src/Migration/Resources/Database/Column.php b/src/Migration/Resources/Database/Column.php index 94c29f2..c1b82e8 100644 --- a/src/Migration/Resources/Database/Column.php +++ b/src/Migration/Resources/Database/Column.php @@ -9,6 +9,7 @@ abstract class Column extends Resource { public const TYPE_STRING = 'string'; public const TYPE_TEXT = 'text'; + public const TYPE_VARCHAR = 'varchar'; public const TYPE_MEDIUMTEXT = 'mediumtext'; public const TYPE_LONGTEXT = 'longtext'; diff --git a/src/Migration/Resources/Database/Columns/Varchar.php b/src/Migration/Resources/Database/Columns/Varchar.php new file mode 100644 index 0000000..9df3a4b --- /dev/null +++ b/src/Migration/Resources/Database/Columns/Varchar.php @@ -0,0 +1,97 @@ + + * }, + * table?: array{ + * database: array{ + * id: string, + * name: string, + * }, + * name: string, + * id: string, + * rowSecurity: bool, + * permissions: ?array + * }, + * required: bool, + * default: ?string, + * array: bool, + * size: int, + * format: string, + * 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'] ?? null, + array: $array['array'], + size: $array['size'], + format: $array['format'], + createdAt: $array['createdAt'] ?? '', + updatedAt: $array['updatedAt'] ?? '', + ); + } + + public function getType(): string + { + return Column::TYPE_VARCHAR; + } + + public function getSize(): int + { + return $this->size; + } + + public function getFormat(): string + { + return $this->format; + } +} diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index c8624fb..c99b667 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -36,6 +36,7 @@ use Utopia\Migration\Resources\Database\Columns\Relationship; use Utopia\Migration\Resources\Database\Columns\Text; use Utopia\Migration\Resources\Database\Columns\URL; +use Utopia\Migration\Resources\Database\Columns\Varchar; use Utopia\Migration\Resources\Database\Database; use Utopia\Migration\Resources\Database\Index; use Utopia\Migration\Resources\Database\Row; @@ -1094,6 +1095,19 @@ private function exportColumns(int $batchSize): void ); break; + case Column::TYPE_VARCHAR: + $col = new Varchar( + $column['key'], + $table, + required: $column['required'], + default: $column['default'], + array: $column['array'], + size: $column['size'] ?? 255, + createdAt: $column['$createdAt'] ?? '', + updatedAt: $column['$updatedAt'] ?? '', + ); + break; + case Column::TYPE_TEXT: $col = new RegularText( $column['key'], From 75c9b9ac8ee4827163711e1aedced2bafb8f265b Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 17 Feb 2026 10:54:05 +0530 Subject: [PATCH 06/10] chore: bump storage lib --- composer.json | 2 +- composer.lock | 189 ++++++++++++++++++++++++++------------------------ 2 files changed, 101 insertions(+), 90 deletions(-) diff --git a/composer.json b/composer.json index 3430b0e..5585f2a 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "ext-openssl": "*", "appwrite/appwrite": "19.*", "utopia-php/database": "5.*", - "utopia-php/storage": "0.18.*", + "utopia-php/storage": "1.0.*", "utopia-php/dsn": "0.2.*", "halaxa/json-machine": "^1.2" }, diff --git a/composer.lock b/composer.lock index ee17709..17d1422 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": "29e79affc489fb76f06516f9821306d2", + "content-hash": "37980b9001fbbd4f213f3102c1332727", "packages": [ { "name": "appwrite/appwrite", @@ -50,16 +50,16 @@ }, { "name": "brick/math", - "version": "0.14.1", + "version": "0.14.8", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "f05858549e5f9d7bb45875a75583240a38a281d0" + "reference": "63422359a44b7f06cae63c3b429b59e8efcc0629" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/f05858549e5f9d7bb45875a75583240a38a281d0", - "reference": "f05858549e5f9d7bb45875a75583240a38a281d0", + "url": "https://api.github.com/repos/brick/math/zipball/63422359a44b7f06cae63c3b429b59e8efcc0629", + "reference": "63422359a44b7f06cae63c3b429b59e8efcc0629", "shasum": "" }, "require": { @@ -98,7 +98,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.14.1" + "source": "https://github.com/brick/math/tree/0.14.8" }, "funding": [ { @@ -106,7 +106,7 @@ "type": "github" } ], - "time": "2025-11-24T14:40:29+00:00" + "time": "2026-02-10T14:33:43+00:00" }, { "name": "composer/semver", @@ -643,16 +643,16 @@ }, { "name": "open-telemetry/exporter-otlp", - "version": "1.3.4", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/exporter-otlp.git", - "reference": "62e680d587beb42e5247aa6ecd89ad1ca406e8ca" + "reference": "283a0d66522f2adc6d8d7debfd7686be91c282be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/62e680d587beb42e5247aa6ecd89ad1ca406e8ca", - "reference": "62e680d587beb42e5247aa6ecd89ad1ca406e8ca", + "url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/283a0d66522f2adc6d8d7debfd7686be91c282be", + "reference": "283a0d66522f2adc6d8d7debfd7686be91c282be", "shasum": "" }, "require": { @@ -703,7 +703,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2026-01-15T09:31:34+00:00" + "time": "2026-02-05T09:44:52+00:00" }, { "name": "open-telemetry/gen-otlp-protobuf", @@ -770,16 +770,16 @@ }, { "name": "open-telemetry/sdk", - "version": "1.12.0", + "version": "1.13.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/sdk.git", - "reference": "7f1bd524465c1ca42755a9ef1143ba09913f5be0" + "reference": "c76f91203bf7ef98ab3f4e0a82ca21699af185e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/7f1bd524465c1ca42755a9ef1143ba09913f5be0", - "reference": "7f1bd524465c1ca42755a9ef1143ba09913f5be0", + "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/c76f91203bf7ef98ab3f4e0a82ca21699af185e1", + "reference": "c76f91203bf7ef98ab3f4e0a82ca21699af185e1", "shasum": "" }, "require": { @@ -863,7 +863,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2026-01-21T04:14:03+00:00" + "time": "2026-01-28T11:38:11+00:00" }, { "name": "open-telemetry/sem-conv", @@ -2228,16 +2228,16 @@ }, { "name": "utopia-php/database", - "version": "5.0.0", + "version": "5.2.1", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "221794bd7de027f9177cd325209e8162ca2520cb" + "reference": "adfdf201144353a1d2ce14bb197ab746079894e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/221794bd7de027f9177cd325209e8162ca2520cb", - "reference": "221794bd7de027f9177cd325209e8162ca2520cb", + "url": "https://api.github.com/repos/utopia-php/database/zipball/adfdf201144353a1d2ce14bb197ab746079894e0", + "reference": "adfdf201144353a1d2ce14bb197ab746079894e0", "shasum": "" }, "require": { @@ -2245,10 +2245,10 @@ "ext-mongodb": "*", "ext-pdo": "*", "php": ">=8.4", - "utopia-php/cache": "1.0.*", + "utopia-php/cache": "1.*", "utopia-php/framework": "0.33.*", - "utopia-php/mongo": "0.11.*", - "utopia-php/pools": "1.0.*" + "utopia-php/mongo": "1.*", + "utopia-php/pools": "1.*" }, "require-dev": { "fakerphp/faker": "1.23.*", @@ -2280,9 +2280,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/5.0.0" + "source": "https://github.com/utopia-php/database/tree/5.2.1" }, - "time": "2026-01-30T06:17:53+00:00" + "time": "2026-02-16T11:01:13+00:00" }, { "name": "utopia-php/dsn", @@ -2333,27 +2333,30 @@ }, { "name": "utopia-php/framework", - "version": "0.33.11", + "version": "0.33.39", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "354ff0d23bfc6e82bea0fe8e89e115cff1af8466" + "reference": "409a258814d664d3a50fa2f48b6695679334d30b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/354ff0d23bfc6e82bea0fe8e89e115cff1af8466", - "reference": "354ff0d23bfc6e82bea0fe8e89e115cff1af8466", + "url": "https://api.github.com/repos/utopia-php/http/zipball/409a258814d664d3a50fa2f48b6695679334d30b", + "reference": "409a258814d664d3a50fa2f48b6695679334d30b", "shasum": "" }, "require": { - "php": ">=8.0", - "utopia-php/compression": "0.1.*" + "php": ">=8.3", + "utopia-php/compression": "0.1.*", + "utopia-php/telemetry": "0.2.*", + "utopia-php/validators": "0.2.*" }, "require-dev": { - "laravel/pint": "^1.2", - "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.5.25" + "laravel/pint": "1.*", + "phpbench/phpbench": "1.*", + "phpstan/phpstan": "1.*", + "phpunit/phpunit": "9.*", + "swoole/ide-helper": "^6.0" }, "type": "library", "autoload": { @@ -2373,22 +2376,22 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.11" + "source": "https://github.com/utopia-php/http/tree/0.33.39" }, - "time": "2024-11-08T18:47:43+00:00" + "time": "2026-02-11T06:33:42+00:00" }, { "name": "utopia-php/mongo", - "version": "0.11.0", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/utopia-php/mongo.git", - "reference": "34bc0cda8ea368cde68702a6fffe2c3ac625398e" + "reference": "45bedf36c2c946ec7a0a3e59b9f12f772de0b01d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/mongo/zipball/34bc0cda8ea368cde68702a6fffe2c3ac625398e", - "reference": "34bc0cda8ea368cde68702a6fffe2c3ac625398e", + "url": "https://api.github.com/repos/utopia-php/mongo/zipball/45bedf36c2c946ec7a0a3e59b9f12f772de0b01d", + "reference": "45bedf36c2c946ec7a0a3e59b9f12f772de0b01d", "shasum": "" }, "require": { @@ -2434,9 +2437,9 @@ ], "support": { "issues": "https://github.com/utopia-php/mongo/issues", - "source": "https://github.com/utopia-php/mongo/tree/0.11.0" + "source": "https://github.com/utopia-php/mongo/tree/1.0.0" }, - "time": "2025-10-20T11:11:23+00:00" + "time": "2026-02-12T05:54:06+00:00" }, { "name": "utopia-php/pools", @@ -2493,32 +2496,27 @@ }, { "name": "utopia-php/storage", - "version": "0.18.22", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "c46bd78c1f52281df89f8921159782b20260ce31" + "reference": "f672e8865938e5d1d6dc3bd149ceba4e5582199e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/c46bd78c1f52281df89f8921159782b20260ce31", - "reference": "c46bd78c1f52281df89f8921159782b20260ce31", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/f672e8865938e5d1d6dc3bd149ceba4e5582199e", + "reference": "f672e8865938e5d1d6dc3bd149ceba4e5582199e", "shasum": "" }, "require": { - "ext-brotli": "*", "ext-curl": "*", "ext-fileinfo": "*", - "ext-lz4": "*", "ext-simplexml": "*", - "ext-snappy": "*", - "ext-xz": "*", "ext-zlib": "*", - "ext-zstd": "*", "php": ">=8.1", "utopia-php/system": "0.*.*", "utopia-php/telemetry": "0.2.*", - "utopia-php/validators": "0.1.*" + "utopia-php/validators": "0.2.*" }, "require-dev": { "laravel/pint": "1.2.*", @@ -2545,9 +2543,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.22" + "source": "https://github.com/utopia-php/storage/tree/1.0.0" }, - "time": "2026-01-15T01:36:39+00:00" + "time": "2026-02-17T04:37:10+00:00" }, { "name": "utopia-php/system", @@ -2662,16 +2660,16 @@ }, { "name": "utopia-php/validators", - "version": "0.1.0", + "version": "0.2.0", "source": { "type": "git", "url": "https://github.com/utopia-php/validators.git", - "reference": "5c57d5b6cf964f8981807c1d3ea8df620c869080" + "reference": "30b6030a5b100fc1dff34506e5053759594b2a20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/validators/zipball/5c57d5b6cf964f8981807c1d3ea8df620c869080", - "reference": "5c57d5b6cf964f8981807c1d3ea8df620c869080", + "url": "https://api.github.com/repos/utopia-php/validators/zipball/30b6030a5b100fc1dff34506e5053759594b2a20", + "reference": "30b6030a5b100fc1dff34506e5053759594b2a20", "shasum": "" }, "require": { @@ -2679,7 +2677,7 @@ }, "require-dev": { "laravel/pint": "1.*", - "phpstan/phpstan": "1.*", + "phpstan/phpstan": "2.*", "phpunit/phpunit": "11.*" }, "type": "library", @@ -2701,9 +2699,9 @@ ], "support": { "issues": "https://github.com/utopia-php/validators/issues", - "source": "https://github.com/utopia-php/validators/tree/0.1.0" + "source": "https://github.com/utopia-php/validators/tree/0.2.0" }, - "time": "2025-11-18T11:05:46+00:00" + "time": "2026-01-13T09:16:51+00:00" } ], "packages-dev": [ @@ -2771,16 +2769,16 @@ }, { "name": "laravel/pint", - "version": "v1.27.0", + "version": "v1.27.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "c67b4195b75491e4dfc6b00b1c78b68d86f54c90" + "reference": "54cca2de13790570c7b6f0f94f37896bee4abcb5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/c67b4195b75491e4dfc6b00b1c78b68d86f54c90", - "reference": "c67b4195b75491e4dfc6b00b1c78b68d86f54c90", + "url": "https://api.github.com/repos/laravel/pint/zipball/54cca2de13790570c7b6f0f94f37896bee4abcb5", + "reference": "54cca2de13790570c7b6f0f94f37896bee4abcb5", "shasum": "" }, "require": { @@ -2791,13 +2789,13 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.92.4", - "illuminate/view": "^12.44.0", - "larastan/larastan": "^3.8.1", - "laravel-zero/framework": "^12.0.4", + "friendsofphp/php-cs-fixer": "^3.93.1", + "illuminate/view": "^12.51.0", + "larastan/larastan": "^3.9.2", + "laravel-zero/framework": "^12.0.5", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^2.3.3", - "pestphp/pest": "^3.8.4" + "pestphp/pest": "^3.8.5" }, "bin": [ "builds/pint" @@ -2834,7 +2832,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2026-01-05T16:49:17+00:00" + "time": "2026-02-10T20:00:20+00:00" }, { "name": "myclabs/deep-copy", @@ -3292,28 +3290,28 @@ }, { "name": "phpunit/php-file-iterator", - "version": "5.1.0", + "version": "5.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6" + "reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6", - "reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/2f3a64888c814fc235386b7387dd5b5ed92ad903", + "reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903", "shasum": "" }, "require": { "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -3341,15 +3339,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.0" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.1" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/php-file-iterator", + "type": "tidelift" } ], - "time": "2024-08-27T05:02:59+00:00" + "time": "2026-02-02T13:52:54+00:00" }, { "name": "phpunit/php-invoker", @@ -3537,16 +3547,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.50", + "version": "11.5.53", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "fdfc727f0fcacfeb8fcb30c7e5da173125b58be3" + "reference": "a997a653a82845f1240d73ee73a8a4e97e4b0607" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fdfc727f0fcacfeb8fcb30c7e5da173125b58be3", - "reference": "fdfc727f0fcacfeb8fcb30c7e5da173125b58be3", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a997a653a82845f1240d73ee73a8a4e97e4b0607", + "reference": "a997a653a82845f1240d73ee73a8a4e97e4b0607", "shasum": "" }, "require": { @@ -3561,7 +3571,7 @@ "phar-io/version": "^3.2.1", "php": ">=8.2", "phpunit/php-code-coverage": "^11.0.12", - "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-file-iterator": "^5.1.1", "phpunit/php-invoker": "^5.0.1", "phpunit/php-text-template": "^4.0.1", "phpunit/php-timer": "^7.0.1", @@ -3573,6 +3583,7 @@ "sebastian/exporter": "^6.3.2", "sebastian/global-state": "^7.0.2", "sebastian/object-enumerator": "^6.0.1", + "sebastian/recursion-context": "^6.0.3", "sebastian/type": "^5.1.3", "sebastian/version": "^5.0.2", "staabm/side-effects-detector": "^1.0.5" @@ -3618,7 +3629,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.50" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.53" }, "funding": [ { @@ -3642,7 +3653,7 @@ "type": "tidelift" } ], - "time": "2026-01-27T05:59:18+00:00" + "time": "2026-02-10T12:28:25+00:00" }, { "name": "sebastian/cli-parser", @@ -4986,7 +4997,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { From 9e4b94595331e6cc334b7943ffffdc84e099d64f Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 18 Feb 2026 15:36:29 +0530 Subject: [PATCH 07/10] removed redundant attribute addition making the column as the single source --- .../Resources/Database/Attribute/Boolean.php | 78 -------- .../Resources/Database/Attribute/DateTime.php | 79 -------- .../Resources/Database/Attribute/Decimal.php | 105 ---------- .../Resources/Database/Attribute/Email.php | 37 ---- .../Resources/Database/Attribute/Enum.php | 102 ---------- .../Resources/Database/Attribute/IP.php | 37 ---- .../Resources/Database/Attribute/Integer.php | 109 ---------- .../Resources/Database/Attribute/Line.php | 74 ------- .../Database/Attribute/ObjectType.php | 74 ------- .../Resources/Database/Attribute/Point.php | 74 ------- .../Resources/Database/Attribute/Polygon.php | 74 ------- .../Database/Attribute/Relationship.php | 125 ------------ .../Resources/Database/Attribute/Text.php | 97 --------- .../Resources/Database/Attribute/URL.php | 37 ---- .../Resources/Database/Attribute/Vector.php | 78 -------- src/Migration/Resources/Database/Column.php | 12 ++ .../Resources/Database/GenericAttribute.php | 98 +++++++++ src/Migration/Sources/Appwrite.php | 189 ++---------------- 18 files changed, 123 insertions(+), 1356 deletions(-) delete mode 100644 src/Migration/Resources/Database/Attribute/Boolean.php delete mode 100644 src/Migration/Resources/Database/Attribute/DateTime.php delete mode 100644 src/Migration/Resources/Database/Attribute/Decimal.php delete mode 100644 src/Migration/Resources/Database/Attribute/Email.php delete mode 100644 src/Migration/Resources/Database/Attribute/Enum.php delete mode 100644 src/Migration/Resources/Database/Attribute/IP.php delete mode 100644 src/Migration/Resources/Database/Attribute/Integer.php delete mode 100644 src/Migration/Resources/Database/Attribute/Line.php delete mode 100644 src/Migration/Resources/Database/Attribute/ObjectType.php delete mode 100644 src/Migration/Resources/Database/Attribute/Point.php delete mode 100644 src/Migration/Resources/Database/Attribute/Polygon.php delete mode 100644 src/Migration/Resources/Database/Attribute/Relationship.php delete mode 100644 src/Migration/Resources/Database/Attribute/Text.php delete mode 100644 src/Migration/Resources/Database/Attribute/URL.php delete mode 100644 src/Migration/Resources/Database/Attribute/Vector.php create mode 100644 src/Migration/Resources/Database/GenericAttribute.php diff --git a/src/Migration/Resources/Database/Attribute/Boolean.php b/src/Migration/Resources/Database/Attribute/Boolean.php deleted file mode 100644 index 6bbe4b1..0000000 --- a/src/Migration/Resources/Database/Attribute/Boolean.php +++ /dev/null @@ -1,78 +0,0 @@ - - * }, - * table?: array{ - * database: array{ - * id: string, - * name: string, - * }, - * name: string, - * id: string, - * rowSecurity: bool, - * permissions: ?array - * }, - * required: bool, - * array: bool, - * default: ?bool, - * createdAt: string, - * updatedAt: string, - * } $array - * @return self - */ - public static function fromArray(array $array): self - { - return new self( - $array['key'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - default: $array['default'], - array: $array['array'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_BOOLEAN; - } -} diff --git a/src/Migration/Resources/Database/Attribute/DateTime.php b/src/Migration/Resources/Database/Attribute/DateTime.php deleted file mode 100644 index f81a375..0000000 --- a/src/Migration/Resources/Database/Attribute/DateTime.php +++ /dev/null @@ -1,79 +0,0 @@ - - * }, - * table?: array{ - * database: array{ - * id: string, - * name: string, - * }, - * name: string, - * id: string, - * rowSecurity: bool, - * permissions: ?array - * }, - * required: bool, - * array: bool, - * default: ?string, - * createdAt: string, - * updatedAt: string, - * } $array - * @return self - */ - public static function fromArray(array $array): self - { - return new self( - $array['key'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - default: $array['default'], - array: $array['array'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } -} diff --git a/src/Migration/Resources/Database/Attribute/Decimal.php b/src/Migration/Resources/Database/Attribute/Decimal.php deleted file mode 100644 index acbcad4..0000000 --- a/src/Migration/Resources/Database/Attribute/Decimal.php +++ /dev/null @@ -1,105 +0,0 @@ - $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: ?float, - * formatOptions: array{ - * min: ?float, - * max: ?float - * }, - * createdAt: string, - * updatedAt: string, - * } $array - * @return self - */ - public static function fromArray(array $array): self - { - return new self( - $array['key'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - default: $array['default'], - array: $array['array'], - min: $array['formatOptions']['min'], - max: $array['formatOptions']['max'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_FLOAT; - } - - public function getMin(): ?float - { - return (float)$this->formatOptions['min']; - } - - public function getMax(): ?float - { - return (float)$this->formatOptions['max']; - } -} diff --git a/src/Migration/Resources/Database/Attribute/Email.php b/src/Migration/Resources/Database/Attribute/Email.php deleted file mode 100644 index 2c460f3..0000000 --- a/src/Migration/Resources/Database/Attribute/Email.php +++ /dev/null @@ -1,37 +0,0 @@ - $elements - */ - public function __construct( - string $key, - Collection $collection, - array $elements, - bool $required = false, - ?string $default = null, - bool $array = false, - int $size = 256, - string $createdAt = '', - string $updatedAt = '' - ) { - parent::__construct( - $key, - $collection, - size: $size, - required: $required, - default: $default, - array: $array, - format: 'enum', - formatOptions: [ - 'elements' => $elements, - ], - 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 - * }, - * size: int, - * required: bool, - * default: ?string, - * array: bool, - * formatOptions: array{ - * elements: array - * }, - * createdAt: string, - * updatedAt: string, - * } $array - * @return self - */ - public static function fromArray(array $array): self - { - return new self( - $array['key'], - Collection::fromArray($array['table'] ?? $array['collection']), - elements: $array['formatOptions']['elements'], - required: $array['required'], - default: $array['default'], - array: $array['array'], - size: $array['size'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_ENUM; - } - - /** - * @return array - */ - public function getElements(): array - { - return (array)$this->formatOptions['elements']; - } -} diff --git a/src/Migration/Resources/Database/Attribute/IP.php b/src/Migration/Resources/Database/Attribute/IP.php deleted file mode 100644 index e2be9ad..0000000 --- a/src/Migration/Resources/Database/Attribute/IP.php +++ /dev/null @@ -1,37 +0,0 @@ - 2147483647 ? 8 : 4; - - parent::__construct( - $key, - $collection, - 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 - * }, - * 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, - * signed?: bool - * } $array - * @return self - */ - public static function fromArray(array $array): self - { - return new self( - $array['key'], - Collection::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'] ?? '', - signed: $array['signed'] ?? true - ); - } - - public function getType(): string - { - return Attribute::TYPE_INTEGER; - } - - public function getMin(): ?int - { - return (int)$this->formatOptions['min']; - } - - public function getMax(): ?int - { - return (int)$this->formatOptions['max']; - } -} diff --git a/src/Migration/Resources/Database/Attribute/Line.php b/src/Migration/Resources/Database/Attribute/Line.php deleted file mode 100644 index dfa360a..0000000 --- a/src/Migration/Resources/Database/Attribute/Line.php +++ /dev/null @@ -1,74 +0,0 @@ - - * }, - * 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'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - default: $array['default'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_LINE; - } -} diff --git a/src/Migration/Resources/Database/Attribute/ObjectType.php b/src/Migration/Resources/Database/Attribute/ObjectType.php deleted file mode 100644 index e3ef99d..0000000 --- a/src/Migration/Resources/Database/Attribute/ObjectType.php +++ /dev/null @@ -1,74 +0,0 @@ - - * }, - * 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'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - default: $array['default'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_OBJECT; - } -} diff --git a/src/Migration/Resources/Database/Attribute/Point.php b/src/Migration/Resources/Database/Attribute/Point.php deleted file mode 100644 index a82d7d3..0000000 --- a/src/Migration/Resources/Database/Attribute/Point.php +++ /dev/null @@ -1,74 +0,0 @@ - - * }, - * 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'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - default: $array['default'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_POINT; - } -} diff --git a/src/Migration/Resources/Database/Attribute/Polygon.php b/src/Migration/Resources/Database/Attribute/Polygon.php deleted file mode 100644 index 173eec6..0000000 --- a/src/Migration/Resources/Database/Attribute/Polygon.php +++ /dev/null @@ -1,74 +0,0 @@ - - * }, - * 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'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - default: $array['default'] ?? null, - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_POLYGON; - } -} diff --git a/src/Migration/Resources/Database/Attribute/Relationship.php b/src/Migration/Resources/Database/Attribute/Relationship.php deleted file mode 100644 index aa252ab..0000000 --- a/src/Migration/Resources/Database/Attribute/Relationship.php +++ /dev/null @@ -1,125 +0,0 @@ - $relatedTable, - 'relationType' => $relationType, - 'twoWay' => $twoWay, - 'twoWayKey' => $twoWayKey, - 'onDelete' => $onDelete, - 'side' => $side, - ], - 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 - * }, - * options: array{ - * relatedCollection: string, - * relationType: string, - * twoWay: bool, - * twoWayKey: ?string, - * onDelete: string, - * side: string, - * }, - * createdAt: string, - * updatedAt: string, - * } $array - * @return self - */ - public static function fromArray(array $array): self - { - return new self( - $array['key'], - Collection::fromArray($array['table'] ?? $array['collection']), - relatedTable: $array['options']['relatedTable'] ?? $array['options']['relatedCollection'], - relationType: $array['options']['relationType'], - twoWay: $array['options']['twoWay'], - twoWayKey: $array['options']['twoWayKey'], - onDelete: $array['options']['onDelete'], - side: $array['options']['side'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_RELATIONSHIP; - } - - public function getRelatedTable(): string - { - return $this->options['relatedTable'] ?? $this->options['relatedCollection']; - } - - public function getRelationType(): string - { - return $this->options['relationType']; - } - - public function getTwoWay(): bool - { - return $this->options['twoWay']; - } - - public function getTwoWayKey(): ?string - { - return $this->options['twoWayKey']; - } - - public function getOnDelete(): string - { - return $this->options['onDelete']; - } - - public function getSide(): string - { - return $this->options['side']; - } -} diff --git a/src/Migration/Resources/Database/Attribute/Text.php b/src/Migration/Resources/Database/Attribute/Text.php deleted file mode 100644 index a0c60ec..0000000 --- a/src/Migration/Resources/Database/Attribute/Text.php +++ /dev/null @@ -1,97 +0,0 @@ - - * }, - * table?: array{ - * database: array{ - * id: string, - * name: string, - * }, - * name: string, - * id: string, - * rowSecurity: bool, - * permissions: ?array - * }, - * required: bool, - * default: ?string, - * array: bool, - * size: int, - * format: string, - * createdAt: string, - * updatedAt: string, - * } $array - * @return self - */ - public static function fromArray(array $array): self - { - return new self( - $array['key'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - default: $array['default'] ?? null, - array: $array['array'], - size: $array['size'], - format: $array['format'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_STRING; - } - - public function getSize(): int - { - return $this->size; - } - - public function getFormat(): string - { - return $this->format; - } -} diff --git a/src/Migration/Resources/Database/Attribute/URL.php b/src/Migration/Resources/Database/Attribute/URL.php deleted file mode 100644 index 2e83a0f..0000000 --- a/src/Migration/Resources/Database/Attribute/URL.php +++ /dev/null @@ -1,37 +0,0 @@ - - * }, - * table?: array{ - * database: array{ - * id: string, - * name: string, - * }, - * name: string, - * id: string, - * rowSecurity: bool, - * permissions: ?array - * }, - * size: int, - * required: bool, - * default: ?array, - * createdAt: string, - * updatedAt: string, - * } $array - * @return self - */ - public static function fromArray(array $array): self - { - return new self( - $array['key'], - Collection::fromArray($array['table'] ?? $array['collection']), - required: $array['required'], - size:$array['size'], - default: $array['default'], - createdAt: $array['createdAt'] ?? '', - updatedAt: $array['updatedAt'] ?? '', - ); - } - - public function getType(): string - { - return Attribute::TYPE_VECTOR; - } -} diff --git a/src/Migration/Resources/Database/Column.php b/src/Migration/Resources/Database/Column.php index e80d172..b193e52 100644 --- a/src/Migration/Resources/Database/Column.php +++ b/src/Migration/Resources/Database/Column.php @@ -155,4 +155,16 @@ public function &getOptions(): array { return $this->options; } + + /** + * Convert this Column resource to an Attribute resource. + * This provides a deterministic way to derive attributes from columns, + * eliminating the need to maintain duplicate per-type Attribute implementations. + * + * @return Attribute + */ + public function getAttribute(): Attribute + { + return GenericAttribute::fromColumn($this); + } } diff --git a/src/Migration/Resources/Database/GenericAttribute.php b/src/Migration/Resources/Database/GenericAttribute.php new file mode 100644 index 0000000..e959739 --- /dev/null +++ b/src/Migration/Resources/Database/GenericAttribute.php @@ -0,0 +1,98 @@ + $formatOptions + * @param array $filters + * @param array $options + * @param string $createdAt + * @param string $updatedAt + */ + public function __construct( + string $key, + Table $table, + protected readonly string $fieldType, + int $size = 0, + bool $required = false, + mixed $default = null, + bool $array = false, + bool $signed = false, + string $format = '', + array $formatOptions = [], + array $filters = [], + array $options = [], + string $createdAt = '', + string $updatedAt = '', + ) { + parent::__construct( + $key, + $table, + $size, + $required, + $default, + $array, + $signed, + $format, + $formatOptions, + $filters, + $options, + $createdAt, + $updatedAt + ); + } + + /** + * Convert a Column resource to an Attribute resource. + * This provides a deterministic way to derive attributes from columns. + * + * @param Column $column + * @return self + */ + public static function fromColumn(Column $column): self + { + return new self( + $column->getKey(), + $column->getTable(), + $column->getType(), + $column->getSize(), + $column->isRequired(), + $column->getDefault(), + $column->isArray(), + $column->isSigned(), + $column->getFormat(), + $column->getFormatOptions(), + $column->getFilters(), + $column->getOptions(), + $column->getCreatedAt(), + $column->getUpdatedAt() + ); + } + + /** + * Returns the field type (e.g., 'string', 'integer', 'email'). + * This is stored separately from the resource name (which is 'attribute'). + * + * @return string + */ + public function getType(): string + { + return $this->fieldType; + } +} diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index 321cd85..1ec3f29 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -21,21 +21,6 @@ use Utopia\Migration\Resources\Auth\Team; use Utopia\Migration\Resources\Auth\User; use Utopia\Migration\Resources\Database\Attribute; -use Utopia\Migration\Resources\Database\Attribute\Boolean as AttributeBoolean; -use Utopia\Migration\Resources\Database\Attribute\DateTime as AttributeDateTime; -use Utopia\Migration\Resources\Database\Attribute\Decimal as AttributeDecimal; -use Utopia\Migration\Resources\Database\Attribute\Email as AttributeEmail; -use Utopia\Migration\Resources\Database\Attribute\Enum as AttributeEnum; -use Utopia\Migration\Resources\Database\Attribute\Integer as AttributeInteger; -use Utopia\Migration\Resources\Database\Attribute\IP as AttributeIP; -use Utopia\Migration\Resources\Database\Attribute\Line as AttributeLine; -use Utopia\Migration\Resources\Database\Attribute\ObjectType as AttributeObjectType; -use Utopia\Migration\Resources\Database\Attribute\Point as AttributePoint; -use Utopia\Migration\Resources\Database\Attribute\Polygon as AttributePolygon; -use Utopia\Migration\Resources\Database\Attribute\Relationship as AttributeRelationship; -use Utopia\Migration\Resources\Database\Attribute\Text as AttributeText; -use Utopia\Migration\Resources\Database\Attribute\URL as AttributeURL; -use Utopia\Migration\Resources\Database\Attribute\Vector as AttributeVector; use Utopia\Migration\Resources\Database\Collection; use Utopia\Migration\Resources\Database\Column; use Utopia\Migration\Resources\Database\Columns\Boolean; @@ -972,7 +957,7 @@ private function exportFields(string $entityType, int $batchSize): void /** @var Table $table */ $col = match($table->getDatabase()->getType()) { - Resource::TYPE_DATABASE_VECTORDB => self::getAttribute($table, $column), + Resource::TYPE_DATABASE_VECTORDB => self::getColumn($table, $column)->getAttribute(), default => self::getColumn($table, $column), }; @@ -2082,168 +2067,20 @@ public static function getColumn(Table $table, mixed $column): Column } + /** + * Convert a raw attribute array to an Attribute resource. + * This is now a thin wrapper that uses getColumn() and then converts to Attribute. + * Since Collection extends Table, we can pass it directly to getColumn(). + * + * @param Collection $collection + * @param mixed $attribute + * @return Attribute + */ public static function getAttribute(Collection $collection, mixed $attribute): Attribute { - return match ($attribute['type']) { - Attribute::TYPE_STRING => match ($attribute['format'] ?? '') { - Attribute::TYPE_EMAIL => new AttributeEmail( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - size: $attribute['size'] ?? 254, - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - Attribute::TYPE_ENUM => new AttributeEnum( - $attribute['key'], - $collection, - elements: $attribute['elements'], - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - size: $attribute['size'] ?? UtopiaDatabase::LENGTH_KEY, - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - Attribute::TYPE_URL => new AttributeURL( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - size: $attribute['size'] ?? 2000, - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - Attribute::TYPE_IP => new AttributeIP( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - size: $attribute['size'] ?? 39, - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - default => new AttributeText( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - size: $attribute['size'] ?? 0, - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - }, - - Attribute::TYPE_BOOLEAN => new AttributeBoolean( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_INTEGER => new AttributeInteger( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - min: $attribute['min'] ?? null, - max: $attribute['max'] ?? null, - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_FLOAT => new AttributeDecimal( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - min: $attribute['min'] ?? null, - max: $attribute['max'] ?? null, - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_RELATIONSHIP => new AttributeRelationship( - $attribute['key'], - $collection, - relatedTable: $attribute['relatedTable'] ?? $attribute['relatedCollection'], - relationType: $attribute['relationType'], - twoWay: $attribute['twoWay'], - twoWayKey: $attribute['twoWayKey'], - onDelete: $attribute['onDelete'], - side: $attribute['side'], - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_DATETIME => new AttributeDateTime( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - array: $attribute['array'], - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_POINT => new AttributePoint( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_LINE => new AttributeLine( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_POLYGON => new AttributePolygon( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_OBJECT => new AttributeObjectType( - $attribute['key'], - $collection, - required: $attribute['required'], - default: $attribute['default'], - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - Attribute::TYPE_VECTOR => new AttributeVector( - $attribute['key'], - $collection, - size: $attribute['size'], - required: $attribute['required'], - default: $attribute['default'], - createdAt: $attribute['$createdAt'] ?? '', - updatedAt: $attribute['$updatedAt'] ?? '', - ), - - default => throw new \InvalidArgumentException("Unsupported attribute type: {$attribute['type']}"), - }; + // Use getColumn() to create the Column resource, then convert to Attribute + // This eliminates duplication - all type-specific logic is in getColumn() + return self::getColumn($collection, $attribute)->getAttribute(); } /** From 98c44a1d2a9e7ac927277ca7493ccbd06f6bfde3 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 18 Feb 2026 15:50:55 +0530 Subject: [PATCH 08/10] improved createField --- src/Migration/Destinations/Appwrite.php | 38 ++++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index d04cb8e..7387907 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -491,24 +491,28 @@ protected function createField(Column|Attribute $resource): bool $resource->setStatus(Resource::STATUS_SKIPPED, 'Columns not supported for DocumentsDB'); return false; } - + // column will be matching attribute as well + // column type will be matching attribute type as well $type = match ($resource->getType()) { - Column::TYPE_DATETIME, Attribute::TYPE_DATETIME => UtopiaDatabase::VAR_DATETIME, - Column::TYPE_BOOLEAN, Attribute::TYPE_BOOLEAN => UtopiaDatabase::VAR_BOOLEAN, - Column::TYPE_INTEGER, Attribute::TYPE_INTEGER => UtopiaDatabase::VAR_INTEGER, - Column::TYPE_FLOAT, Attribute::TYPE_FLOAT => UtopiaDatabase::VAR_FLOAT, - Column::TYPE_RELATIONSHIP, Attribute::TYPE_RELATIONSHIP => UtopiaDatabase::VAR_RELATIONSHIP, - Column::TYPE_STRING, Attribute::TYPE_STRING, - Column::TYPE_IP, Attribute::TYPE_IP, - Column::TYPE_EMAIL, Attribute::TYPE_EMAIL, - Column::TYPE_URL, Attribute::TYPE_URL, - Column::TYPE_ENUM, Attribute::TYPE_ENUM => UtopiaDatabase::VAR_STRING, - Column::TYPE_POINT, Attribute::TYPE_POINT => UtopiaDatabase::VAR_POINT, - Column::TYPE_LINE, Attribute::TYPE_LINE => UtopiaDatabase::VAR_LINESTRING, - Column::TYPE_POLYGON, Attribute::TYPE_POLYGON => UtopiaDatabase::VAR_POLYGON, - Column::TYPE_OBJECT, Attribute::TYPE_OBJECT => UtopiaDatabase::VAR_OBJECT, - Column::TYPE_VECTOR, Attribute::TYPE_VECTOR => UtopiaDatabase::VAR_VECTOR, - default => throw new \Exception('Invalid resource type '.$resource->getType()), + Column::TYPE_DATETIME => UtopiaDatabase::VAR_DATETIME, + Column::TYPE_BOOLEAN => UtopiaDatabase::VAR_BOOLEAN, + Column::TYPE_INTEGER => UtopiaDatabase::VAR_INTEGER, + Column::TYPE_FLOAT => UtopiaDatabase::VAR_FLOAT, + Column::TYPE_RELATIONSHIP => UtopiaDatabase::VAR_RELATIONSHIP, + + Column::TYPE_STRING, + 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_OBJECT => UtopiaDatabase::VAR_OBJECT, + Column::TYPE_VECTOR => UtopiaDatabase::VAR_VECTOR, + + default => throw new \Exception('Invalid resource type ' . $resource->getType()), }; $database = $this->dbForProject->getDocument( From e4872c17cb5dcf56807f267b04c00006268fce1b Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 18 Feb 2026 16:00:45 +0530 Subject: [PATCH 09/10] linting --- src/Migration/Destinations/Appwrite.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index edf229a..1d7522c 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -499,13 +499,13 @@ protected function createField(Column|Attribute $resource): bool Column::TYPE_INTEGER => UtopiaDatabase::VAR_INTEGER, Column::TYPE_FLOAT => UtopiaDatabase::VAR_FLOAT, Column::TYPE_RELATIONSHIP => UtopiaDatabase::VAR_RELATIONSHIP, - + Column::TYPE_STRING, 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, @@ -515,7 +515,7 @@ protected function createField(Column|Attribute $resource): bool Column::TYPE_LONGTEXT => UtopiaDatabase::VAR_LONGTEXT, Column::TYPE_OBJECT => UtopiaDatabase::VAR_OBJECT, Column::TYPE_VECTOR => UtopiaDatabase::VAR_VECTOR, - + default => throw new \Exception('Invalid resource type ' . $resource->getType()), }; From 8431f1fa70245f46cc8a50af3181b8551050527c Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Tue, 24 Feb 2026 10:26:37 +0530 Subject: [PATCH 10/10] removed generic attribute and using Attribute as the base --- .../Resources/Database/Attribute.php | 35 ++++++- src/Migration/Resources/Database/Column.php | 2 +- .../Resources/Database/GenericAttribute.php | 98 ------------------- 3 files changed, 34 insertions(+), 101 deletions(-) delete mode 100644 src/Migration/Resources/Database/GenericAttribute.php diff --git a/src/Migration/Resources/Database/Attribute.php b/src/Migration/Resources/Database/Attribute.php index 244f2ba..44e0bd1 100644 --- a/src/Migration/Resources/Database/Attribute.php +++ b/src/Migration/Resources/Database/Attribute.php @@ -5,7 +5,7 @@ use Utopia\Migration\Resource; use Utopia\Migration\Transfer; -abstract class Attribute extends Resource +class Attribute extends Resource { public const TYPE_STRING = 'string'; public const TYPE_INTEGER = 'integer'; @@ -28,6 +28,7 @@ abstract class Attribute extends Resource /** * @param string $key * @param Table $table + * @param string $fieldType The actual field type (e.g., 'string', 'integer', 'email') * @param int $size * @param bool $required * @param mixed|null $default @@ -43,6 +44,7 @@ abstract class Attribute extends Resource public function __construct( protected readonly string $key, protected readonly Table $table, + protected readonly string $fieldType = '', protected readonly int $size = 0, protected readonly bool $required = false, protected readonly mixed $default = null, @@ -85,7 +87,36 @@ public static function getName(): string return Resource::TYPE_ATTRIBUTE; } - abstract public function getType(): string; + public function getType(): string + { + return $this->fieldType; + } + + /** + * Convert a Column resource to an Attribute resource. + * + * @param Column $column + * @return self + */ + public static function fromColumn(Column $column): self + { + return new self( + $column->getKey(), + $column->getTable(), + $column->getType(), + $column->getSize(), + $column->isRequired(), + $column->getDefault(), + $column->isArray(), + $column->isSigned(), + $column->getFormat(), + $column->getFormatOptions(), + $column->getFilters(), + $column->getOptions(), + $column->getCreatedAt(), + $column->getUpdatedAt() + ); + } public function getGroup(): string { diff --git a/src/Migration/Resources/Database/Column.php b/src/Migration/Resources/Database/Column.php index ed13c95..45aea6d 100644 --- a/src/Migration/Resources/Database/Column.php +++ b/src/Migration/Resources/Database/Column.php @@ -170,6 +170,6 @@ public function &getOptions(): array */ public function getAttribute(): Attribute { - return GenericAttribute::fromColumn($this); + return Attribute::fromColumn($this); } } diff --git a/src/Migration/Resources/Database/GenericAttribute.php b/src/Migration/Resources/Database/GenericAttribute.php deleted file mode 100644 index e959739..0000000 --- a/src/Migration/Resources/Database/GenericAttribute.php +++ /dev/null @@ -1,98 +0,0 @@ - $formatOptions - * @param array $filters - * @param array $options - * @param string $createdAt - * @param string $updatedAt - */ - public function __construct( - string $key, - Table $table, - protected readonly string $fieldType, - int $size = 0, - bool $required = false, - mixed $default = null, - bool $array = false, - bool $signed = false, - string $format = '', - array $formatOptions = [], - array $filters = [], - array $options = [], - string $createdAt = '', - string $updatedAt = '', - ) { - parent::__construct( - $key, - $table, - $size, - $required, - $default, - $array, - $signed, - $format, - $formatOptions, - $filters, - $options, - $createdAt, - $updatedAt - ); - } - - /** - * Convert a Column resource to an Attribute resource. - * This provides a deterministic way to derive attributes from columns. - * - * @param Column $column - * @return self - */ - public static function fromColumn(Column $column): self - { - return new self( - $column->getKey(), - $column->getTable(), - $column->getType(), - $column->getSize(), - $column->isRequired(), - $column->getDefault(), - $column->isArray(), - $column->isSigned(), - $column->getFormat(), - $column->getFormatOptions(), - $column->getFilters(), - $column->getOptions(), - $column->getCreatedAt(), - $column->getUpdatedAt() - ); - } - - /** - * Returns the field type (e.g., 'string', 'integer', 'email'). - * This is stored separately from the resource name (which is 'attribute'). - * - * @return string - */ - public function getType(): string - { - return $this->fieldType; - } -}