mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Finish Renaming to Migrations
This commit is contained in:
@@ -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,
|
||||
|
||||
+10
-10
@@ -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,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -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.',
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
@@ -51,8 +51,8 @@ $admins = [
|
||||
'functions.write',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
'imports.read',
|
||||
'imports.write'
|
||||
'migrations.read',
|
||||
'migrations.write'
|
||||
];
|
||||
|
||||
return [
|
||||
|
||||
@@ -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.',
|
||||
]
|
||||
];
|
||||
|
||||
@@ -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',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -187,7 +187,7 @@ class MigrationsV1 extends Worker
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Import
|
||||
* Process Migration
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -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 = '';
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,8 +81,8 @@ trait ProjectCustom
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read',
|
||||
'imports.read',
|
||||
'imports.write'
|
||||
'migrations.read',
|
||||
'migrations.write'
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user