diff --git a/app/config/collections.php b/app/config/collections.php index 1f657f2702..f7b7bb65db 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3697,13 +3697,6 @@ $collections = [ 'lengths' => [Database::LENGTH_KEY], 'orders' => [Database::ORDER_ASC], ], - [ - '$id' => '_key_statusCounters', - 'type' => Database::INDEX_KEY, - 'attributes' => ['statusCounters'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], [ '$id' => ID::custom('_fulltext_search'), 'type' => Database::INDEX_FULLTEXT, diff --git a/app/config/errors.php b/app/config/errors.php index f0521f1cc2..f884e49a42 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -584,20 +584,20 @@ return [ 'description' => 'Too many queries.', 'code' => 400, ], - // Imports - Exception::IMPORT_NOT_FOUND => [ - 'name' => Exception::IMPORT_NOT_FOUND, - 'description' => 'Import with the requested ID could not be found.', + // Migrations + Exception::MIGRATION_NOT_FOUND => [ + 'name' => Exception::MIGRATION_NOT_FOUND, + 'description' => 'Migration with the requested ID could not be found.', 'code' => 404, ], - Exception::IMPORT_ALREADY_EXISTS => [ - 'name' => Exception::IMPORT_ALREADY_EXISTS, - 'description' => 'Import with the requested ID already exists.', + Exception::MIGRATION_ALREADY_EXISTS => [ + 'name' => Exception::MIGRATION_ALREADY_EXISTS, + 'description' => 'Migration with the requested ID already exists.', 'code' => 409, ], - Exception::IMPORT_IN_PROGRESS => [ - 'name' => Exception::IMPORT_IN_PROGRESS, - 'description' => 'Import is already in progress.', + Exception::MIGRATION_IN_PROGRESS => [ + 'name' => Exception::MIGRATION_IN_PROGRESS, + 'description' => 'Migration is already in progress.', 'code' => 409, ], ]; diff --git a/app/config/events.php b/app/config/events.php index 97da122057..e22a53d5d0 100644 --- a/app/config/events.php +++ b/app/config/events.php @@ -237,18 +237,18 @@ return [ '$description' => 'This event triggers when a function is updated.', ] ], - 'imports' => [ + 'migrations' => [ '$model' => Response::MODEL_MIGRATION, '$resource' => true, - '$description' => 'This event triggers on any imports event.', + '$description' => 'This event triggers on any migrations event.', 'create' => [ - '$description' => 'This event triggers when an import is created.' + '$description' => 'This event triggers when an migration is created.' ], 'delete' => [ - '$description' => 'This event triggers when an import is deleted.', + '$description' => 'This event triggers when an migration is deleted.', ], 'update' => [ - '$description' => 'This event triggers when an import is updated.', + '$description' => 'This event triggers when an migration is updated.', ] ], ]; diff --git a/app/config/roles.php b/app/config/roles.php index bba45ed8c7..ff565b2d09 100644 --- a/app/config/roles.php +++ b/app/config/roles.php @@ -51,8 +51,8 @@ $admins = [ 'functions.write', 'execution.read', 'execution.write', - 'imports.read', - 'imports.write' + 'migrations.read', + 'migrations.write' ]; return [ diff --git a/app/config/scopes.php b/app/config/scopes.php index 63cced5b98..228945e107 100644 --- a/app/config/scopes.php +++ b/app/config/scopes.php @@ -76,10 +76,10 @@ return [ // List of publicly visible scopes 'health.read' => [ 'description' => 'Access to read your project\'s health status', ], - 'imports.read' => [ - 'description' => 'Access to read your project\'s import logs', + 'migrations.read' => [ + 'description' => 'Access to read your project\'s migration logs', ], - 'imports.write' => [ - 'description' => 'Access to create, update, and delete your project\'s imports.', + 'migrations.write' => [ + 'description' => 'Access to create, update, and delete your project\'s migrations.', ] ]; diff --git a/app/config/services.php b/app/config/services.php index a91c70cbac..e0228e6c27 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -199,17 +199,17 @@ return [ 'optional' => false, 'icon' => '', ], - 'imports' => [ - 'key' => 'imports', - 'name' => 'Imports', - 'subtitle' => 'The Imports service allows you to migrate third-party data to your Appwrite server.', - 'description' => '/docs/services/imports.md', - 'controller' => 'api/imports.php', + 'migrations' => [ + 'key' => 'migrations', + 'name' => 'Migrations', + 'subtitle' => 'The Migrations service allows you to migrate third-party data to your Appwrite server.', + 'description' => '/docs/services/migrations.md', + 'controller' => 'api/migrations.php', 'sdk' => true, 'docs' => true, - 'docsUrl' => 'https://appwrite.io/docs/imports', + 'docsUrl' => 'https://appwrite.io/docs/migrations', 'tests' => true, 'optional' => true, - 'icon' => '/images/services/imports.png', + 'icon' => '/images/services/migrations.png', ], ]; diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 3eab3c8157..23fe4e7e10 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -2,11 +2,9 @@ use Appwrite\Event\Delete; use Appwrite\Event\Event; -use Appwrite\Event\Import; use Appwrite\Event\Migration; use Appwrite\Extend\Exception; use Utopia\Database\Helpers\ID; -use Appwrite\Utopia\Database\Validator\Queries\Imports; use Appwrite\Utopia\Database\Validator\Queries\Migrations; use Appwrite\Utopia\Response; use Utopia\App; @@ -55,7 +53,7 @@ App::get('/v1/migrations') $cursorDocument = $dbForProject->getDocument('migrations', $migrationId); if ($cursorDocument->isEmpty()) { - throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "Import '{$migrationId}' for the 'cursor' value not found."); + throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "Migration '{$migrationId}' for the 'cursor' value not found."); } $cursor->setValue($cursorDocument); @@ -71,7 +69,7 @@ App::get('/v1/migrations') App::get('/v1/migrations/:migrationId') ->groups(['api', 'migrations']) - ->desc('Get Import') + ->desc('Get Migration') ->label('scope', 'migrations.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'migrations') @@ -80,14 +78,14 @@ App::get('/v1/migrations/:migrationId') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_MIGRATION) - ->param('migrationId', '', new UID(), 'Import unique ID.') + ->param('migrationId', '', new UID(), 'Migration unique ID.') ->inject('response') ->inject('dbForProject') ->action(function (string $migrationId, Response $response, Database $dbForProject) { $migration = $dbForProject->getDocument('migrations', $migrationId); if ($migration->isEmpty()) { - throw new Exception(Exception::IMPORT_NOT_FOUND, 'Import not found', 404); + throw new Exception(Exception::MIGRATION_NOT_FOUND, 'Migration not found', 404); } $response->dynamic($migration, Response::MODEL_MIGRATION); @@ -95,7 +93,7 @@ App::get('/v1/migrations/:migrationId') App::post('/v1/migrations/:migrationId') ->groups(['api', 'migrations']) - ->desc('Retry Import') + ->desc('Retry Migration') ->label('scope', 'migrations.write') ->label('event', 'migrations.[migrationId].retry') ->label('audits.event', 'migration.retry') @@ -117,18 +115,18 @@ App::post('/v1/migrations/:migrationId') $migration = $dbForProject->getDocument('migrations', $migrationId); if ($migration->isEmpty()) { - throw new Exception(Exception::IMPORT_NOT_FOUND); + throw new Exception(Exception::MIGRATION_NOT_FOUND); } // if ($migration->getAttribute('status') !== 'failed') { - // throw new Exception(Exception::IMPORT_IN_PROGRESS, 'Import not failed'); + // throw new Exception(Exception::MIGRATION_IN_PROGRESS, 'Migration not failed'); // } $migration ->setAttribute('status', 'pending') ->setAttribute('dateUpdated', \time()); - // Trigger Import + // Trigger Migration $event = new Migration(); $event ->setMigration($migration) @@ -141,7 +139,7 @@ App::post('/v1/migrations/:migrationId') App::delete('/v1/migrations/:migrationId') ->groups(['api', 'migrations']) - ->desc('Delete Import') + ->desc('Delete Migration') ->label('scope', 'migrations.write') ->label('event', 'migrations.[migrationId].delete') ->label('audits.event', 'migrationId.delete') @@ -152,7 +150,7 @@ App::delete('/v1/migrations/:migrationId') ->label('sdk.description', '/docs/references/functions/delete-migration.md') ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) ->label('sdk.response.model', Response::MODEL_NONE) - ->param('migrationId', '', new UID(), 'Import ID.') + ->param('migrationId', '', new UID(), 'Migration ID.') ->inject('response') ->inject('dbForProject') ->inject('deletes') @@ -162,7 +160,7 @@ App::delete('/v1/migrations/:migrationId') $migration = $dbForProject->getDocument('migrations', $migrationId); if ($migration->isEmpty()) { - throw new Exception(Exception::IMPORT_NOT_FOUND, 'Import not found', 404); + throw new Exception(Exception::MIGRATION_NOT_FOUND, 'Migration not found', 404); } if (!$dbForProject->deleteDocument('migrations', $migration->getId())) { @@ -180,7 +178,7 @@ App::delete('/v1/migrations/:migrationId') App::post('/v1/migrations/appwrite') ->groups(['api', 'migrations']) - ->desc('Import Appwrite Data') + ->desc('Migrate Appwrite Data') ->label('scope', 'migrations.write') ->label('event', 'migrations.create') ->label('audits.event', 'migration.create') @@ -234,7 +232,7 @@ App::post('/v1/migrations/appwrite') App::post('/v1/migrations/firebase') ->groups(['api', 'migrations']) - ->desc('Import Firebase Data') + ->desc('Migrate Firebase Data') ->label('scope', 'migrations.write') ->label('event', 'migrations.create') ->label('audits.event', 'migration.create') @@ -284,7 +282,7 @@ App::post('/v1/migrations/firebase') App::post('/v1/migrations/supabase') ->groups(['api', 'migrations']) - ->desc('Import Supabase Data') + ->desc('Migrate Supabase Data') ->label('scope', 'migrations.write') ->label('event', 'migrations.create') ->label('audits.event', 'migration.create') @@ -344,7 +342,7 @@ App::post('/v1/migrations/supabase') App::post('/v1/migrations/nhost') ->groups(['api', 'migrations']) - ->desc('Import NHost Data') + ->desc('Migrate NHost Data') ->label('scope', 'migrations.write') ->label('event', 'migrations.create') ->label('audits.event', 'migration.create') diff --git a/app/workers/migrations.php b/app/workers/migrations.php index 0ef5aae39d..0620723252 100644 --- a/app/workers/migrations.php +++ b/app/workers/migrations.php @@ -187,7 +187,7 @@ class MigrationsV1 extends Worker } /** - * Process Import + * Process Migration * * @return void */ diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 767611556a..e7ad285888 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -189,10 +189,10 @@ class Exception extends \Exception public const GRAPHQL_NO_QUERY = 'graphql_no_query'; public const GRAPHQL_TOO_MANY_QUERIES = 'graphql_too_many_queries'; - /** Imports */ - public const IMPORT_NOT_FOUND = 'import_not_found'; - public const IMPORT_ALREADY_EXISTS = 'import_already_exists'; - public const IMPORT_IN_PROGRESS = 'import_in_progress'; + /** Migrations */ + public const MIGRATION_NOT_FOUND = 'migration_not_found'; + public const MIGRATION_ALREADY_EXISTS = 'migration_already_exists'; + public const MIGRATION_IN_PROGRESS = 'migration_in_progress'; protected $type = ''; diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index bf113136bc..dfa2fa3f97 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -85,7 +85,6 @@ use Appwrite\Utopia\Response\Model\UsageProject; use Appwrite\Utopia\Response\Model\UsageStorage; use Appwrite\Utopia\Response\Model\UsageUsers; use Appwrite\Utopia\Response\Model\Variable; -use Appwrite\Utopia\Response\Model\Import; use Appwrite\Utopia\Response\Model\ImportValidationError; use Appwrite\Utopia\Response\Model\Migration; diff --git a/src/Appwrite/Utopia/Response/Model/ImportValidationError.php b/src/Appwrite/Utopia/Response/Model/ImportValidationError.php index 3757bd5766..a255d39739 100644 --- a/src/Appwrite/Utopia/Response/Model/ImportValidationError.php +++ b/src/Appwrite/Utopia/Response/Model/ImportValidationError.php @@ -13,7 +13,7 @@ class ImportValidationError extends Any */ public function getName(): string { - return 'Import Validiation Error'; + return 'Migration Validiation Error'; } /** @@ -23,6 +23,6 @@ class ImportValidationError extends Any */ public function getType(): string { - return Response::MODEL_MIGRATION_VALIDATION_ERROR; + return Response::MODEL_IMPORT_VALIDATION_ERROR; } } diff --git a/src/Appwrite/Utopia/Response/Model/Migration.php b/src/Appwrite/Utopia/Response/Model/Migration.php index ce87ac4ec6..e59db3e9c3 100644 --- a/src/Appwrite/Utopia/Response/Model/Migration.php +++ b/src/Appwrite/Utopia/Response/Model/Migration.php @@ -12,7 +12,7 @@ class Migration extends Model $this ->addRule('$id', [ 'type' => self::TYPE_STRING, - 'description' => 'Import ID.', + 'description' => 'Migration ID.', 'default' => '', 'example' => '5e5ea5c16897e', ]) @@ -30,38 +30,38 @@ class Migration extends Model ]) ->addRule('status', [ 'type' => self::TYPE_STRING, - 'description' => 'Import status.', + 'description' => 'Migration status.', 'default' => '', 'example' => 'pending', ]) ->addRule('stage', [ 'type' => self::TYPE_STRING, - 'description' => 'Import stage.', + 'description' => 'Migration stage.', 'default' => '', 'example' => 'init', ]) ->addRule('source', [ 'type' => self::TYPE_STRING, - 'description' => 'An object containing the source of the import.', + 'description' => 'An object containing the source of the migration.', 'default' => '', 'example' => '{"type": "Appwrite", "endpoint": "xxxxxxxx", ...}', ]) ->addRule('resources', [ 'type' => self::TYPE_STRING, - 'description' => 'Resources to import.', + 'description' => 'Resources to migration.', 'default' => [], 'example' => ['user'], 'array' => true ]) ->addRule('statusCounters', [ 'type' => self::TYPE_JSON, - 'description' => 'A group of counters that represent the total progress of the import.', + 'description' => 'A group of counters that represent the total progress of the migration.', 'default' => [], 'example' => '{"Database": {"PENDING": 0, "SUCCESS": 1, "ERROR": 0, "SKIP": 0, "PROCESSING": 0, "WARNING": 0}}', ]) ->addRule('resourceData', [ 'type' => self::TYPE_JSON, - 'description' => 'An array of objects containing the report data of the resources that were imported.', + 'description' => 'An array of objects containing the report data of the resources that were migrated.', 'default' => [], 'example' => '[{"resource":"Database","id":"public","status":"SUCCESS","message":""}]', ]) @@ -81,7 +81,7 @@ class Migration extends Model */ public function getName(): string { - return 'Import'; + return 'Migration'; } /** diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index 9b35a1403f..9c71893395 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -81,8 +81,8 @@ trait ProjectCustom 'locale.read', 'avatars.read', 'health.read', - 'imports.read', - 'imports.write' + 'migrations.read', + 'migrations.write' ], ]);