diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 5868695bd3..ef71f8f6ef 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -26,7 +26,7 @@ use Utopia\Database\Validator\Queries\Documents; use Utopia\Database\Validator\Query\Cursor; use Utopia\Database\Validator\UID; use Utopia\Http\Http; -use Utopia\Migration\Destinations\Appwrite as DestinationAppwrite; +use Utopia\Migration\Destinations\OnDuplicate; use Utopia\Migration\Resource; use Utopia\Migration\Sources\Appwrite; use Utopia\Migration\Sources\CSV; @@ -88,7 +88,7 @@ Http::post('/v1/migrations/appwrite') ->param('endpoint', '', new URL(), 'Source Appwrite endpoint') ->param('projectId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Source Project ID', false, ['dbForProject']) ->param('apiKey', '', new Text(512), 'Source API Key') - ->param('onDuplicate', DestinationAppwrite::ON_DUPLICATE_FAIL, new WhiteList(DestinationAppwrite::ON_DUPLICATES), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "upsert": replace existing row.', true) + ->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "upsert": replace existing row.', true) ->inject('response') ->inject('dbForProject') ->inject('project') @@ -357,7 +357,7 @@ Http::post('/v1/migrations/csv/imports') ->param('fileId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'File ID.', false, ['dbForProject']) ->param('resourceId', null, new CompoundUID(), 'Composite ID in the format {databaseId:collectionId}, identifying a collection within a database.') ->param('internalFile', false, new Boolean(), 'Is the file stored in an internal bucket?', true) - ->param('onDuplicate', DestinationAppwrite::ON_DUPLICATE_FAIL, new WhiteList(DestinationAppwrite::ON_DUPLICATES), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "upsert": replace existing row.', true) + ->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "upsert": replace existing row.', true) ->inject('response') ->inject('dbForProject') ->inject('dbForPlatform') @@ -664,7 +664,7 @@ Http::post('/v1/migrations/json/imports') ->param('fileId', '', new UID(), 'File ID.') ->param('resourceId', null, new CompoundUID(), 'Composite ID in the format {databaseId:collectionId}, identifying a collection within a database.') ->param('internalFile', false, new Boolean(), 'Is the file stored in an internal bucket?', true) - ->param('onDuplicate', DestinationAppwrite::ON_DUPLICATE_FAIL, new WhiteList(DestinationAppwrite::ON_DUPLICATES), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "upsert": replace existing row.', true) + ->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "upsert": replace existing row.', true) ->inject('response') ->inject('dbForProject') ->inject('dbForPlatform') diff --git a/composer.json b/composer.json index d8bb03d120..2f8ea37011 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ "utopia-php/locale": "0.8.*", "utopia-php/logger": "0.6.*", "utopia-php/messaging": "0.22.*", - "utopia-php/migration": "dev-feat/skip-duplicates as 1.9.99", + "utopia-php/migration": "1.9.2", "utopia-php/platform": "0.12.*", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", diff --git a/composer.lock b/composer.lock index de21fbef5e..7e09c5cf00 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": "cce51bafc6cbb73585a51e7495b2e6cc", + "content-hash": "8fe5034e4c20ba22c778a666ef451dd9", "packages": [ { "name": "adhocore/jwt", @@ -4526,16 +4526,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-feat/skip-duplicates", + "version": "1.9.2", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "6025318d61c15355015c0e34427480e84ad690ad" + "reference": "97266905f35260137ba0b0e0c4f849f1ee422e43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/6025318d61c15355015c0e34427480e84ad690ad", - "reference": "6025318d61c15355015c0e34427480e84ad690ad", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/97266905f35260137ba0b0e0c4f849f1ee422e43", + "reference": "97266905f35260137ba0b0e0c4f849f1ee422e43", "shasum": "" }, "require": { @@ -4544,7 +4544,7 @@ "ext-openssl": "*", "halaxa/json-machine": "^1.2", "php": ">=8.1", - "utopia-php/database": "5.3.22", + "utopia-php/database": "5.*", "utopia-php/dsn": "0.2.*", "utopia-php/storage": "1.0.*" }, @@ -4575,9 +4575,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/feat/skip-duplicates" + "source": "https://github.com/utopia-php/migration/tree/1.9.2" }, - "time": "2026-04-20T09:07:20+00:00" + "time": "2026-04-20T11:55:43+00:00" }, { "name": "utopia-php/mongo", @@ -8440,18 +8440,9 @@ "time": "2024-11-07T12:36:22+00:00" } ], - "aliases": [ - { - "package": "utopia-php/migration", - "version": "dev-feat/skip-duplicates", - "alias": "1.9.99", - "alias_normalized": "1.9.99.0" - } - ], + "aliases": [], "minimum-stability": "dev", - "stability-flags": { - "utopia-php/migration": 20 - }, + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 6a440e54c0..d88ab23535 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -30,6 +30,7 @@ use Utopia\Migration\Destination; use Utopia\Migration\Destinations\Appwrite as DestinationAppwrite; use Utopia\Migration\Destinations\CSV as DestinationCSV; use Utopia\Migration\Destinations\JSON as DestinationJSON; +use Utopia\Migration\Destinations\OnDuplicate; use Utopia\Migration\Exception as MigrationException; use Utopia\Migration\Resource; use Utopia\Migration\Resources\Database\Database as ResourceDatabase; @@ -276,7 +277,7 @@ class Migrations extends Action $this->dbForProject, $this->getDatabasesDB, Config::getParam('collections', [])['databases']['collections'], - $options['onDuplicate'] ?? DestinationAppwrite::ON_DUPLICATE_FAIL, + OnDuplicate::tryFrom($options['onDuplicate'] ?? '') ?? OnDuplicate::Fail, ), DestinationCSV::getName() => new DestinationCSV( $this->deviceForFiles,